I have a C# program that needs to process CSV files. I have the program working fine when I specify just one file, but I tried to change it to process all CSV files in a specified file directory and it is no longer working correctly. It picks up the files but does not read them. This is the basic structure I'm trying to use:
string[] filePaths = Directory.GetFiles(@"C:\Users\XXXXX\Documents\", "*.csv");
foreach (var file in filePaths)
{
StreamReader streamReader = new StreamReader(file);
try
{
while (!streamReader.EndOfStream)
{
string[] totalData = new string[System.IO.File.ReadAllLines(file).Length];
}
}
}