3
I need to include ZERO to complete the digits of the CPF in the csv file, however, if the CPF starts with ZERO is taken out and only the numbers, that is, has Cpf that saves only 9 digits, because the first two do not enter the account...
public string CreateCSVFile(List<ExcelColumsData> registers)
{
List<string> linesList = new List<string>();
foreach (var item in registers)
{
linesList.Add(item.Licence + ";" + item.CPF.ToString() + ";" + item.CodeANAC + ";" + item.Plate + ";" + item.FullName + ";" + item.BaseContract + ";" + item.IATACODE);
}
string fileName = "G3_" + DateTime.Now.ToString("yyyyMMdd") + ".csv";
FreePassDataContextDataContext dataContext = new FreePassDataContextDataContext(ConfigurationManager.ConnectionStrings["Default"].ConnectionString);
var freePassConfigurationsEntity = dataContext.FreePassConfigurations.FirstOrDefault();
string downloadFolderSFTP = "C:\\ftp\\";
System.IO.File.WriteAllLines(downloadFolderSFTP + fileName, linesList, System.Text.Encoding.GetEncoding("iso-8859-1"));
return fileName;
}
The code appears as string normally, but the CSV file does not. You can help me?
Remembering that no dot or dash is used in the CPF, only the same numbers.
– Ewerton Melo
What commands are used to create your CSV file?
– Leonel Sanches da Silva
I changed the post by putting the whole method.
– Ewerton Melo
Without analyzing your code too much, I found strange the following literal:
";'"
on line 6 (linesList.Add
) because there is no final quote that serves as a delimiter– OnoSendai
This was a test that I made, disregard, in this case it includes the apostrophe in the beginning and prints the 0 however, should not have the apostrophe, sorry my carelessness.
– Ewerton Melo