I have an application that reads .csv files, these files come to me by mail and by means of a macro they are automatically saved in a server directory. The problem is that if the files that are saved automatically by the macro read the program does not detect the values, I need to open them in excel and save them. Similarly, if the files I save directly from the outlook with 'Save as' reads them no problem. When the files arrive they have extension .CSV and when you save them with excel the extension is set to lowercase and you can read them.
These are the two methods with which I read the .cvs files
//Agrega a la lista cada linea del contenido de un archivo .cvs
public void leerCVS(String ruta)
{
var reader = new StreamReader(File.OpenRead(ruta));
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
lista.Add(line);
}
}
public void leerCarpeta()
{
foreach (string file in Directory.GetFiles(path, "*.CSV").Select(Path.GetFileName))
{
leerCVS(path+ "\" +file);
}
}
A tuple of the file:
1910369,PP01,116,4545060955,,3101,265,PLATINADO Sn,16890 - HERRERA LILIANA,<DEL>,,,20180809,40212,8/9/2018,0,STD,14796,EA,0,EA,
This is the result of the debug, where it tells me that I read 276 lines and the variable 'a' is a line of information that should contain all the data separated by commas, but it gives me an empty field