Possible Duplicate:
how to read all files inside particular folder
I have the following code which I came up with:
string[] lines = System.IO.File.ReadAllLines(@"C:\Notes\Variables1.txt");
foreach (string line in lines)
{
process(line);
}
string[] lines = System.IO.File.ReadAllLines(@"C:\Notes\test1.txt");
foreach (string line in lines)
{
process(line);
}
Is there a simple and reliable way that I can modify the code so that it looks up all the .txt files in my Notes directory and then reads each one in turn. Some way I can code this up without having to specify each file in turn and something that won't crash if the file is empty.