I am very new to c# programming, so if my question is trivial I apologize. I am running some c# code where I need to iterate over some files in a folder and am using:
foreach (string f in Directory.GetFiles(@"C:\temp\GeneralStats"))
{
However, I would like to have these files read in a specific order according to file name. My file names are of the below format.
generalstats_2012_11_1.csv generalstats_2012_11_2.csv generalstats_2012_11_3.csv .....
When my code reads in the files it starts with generalstats_2012_11_1.csv but then jumps directly to generalstats_2012_11_10.csv, instead of generalstats_2012_11_2.csv.
I have tried searching the web for answers but have been unable to find any. I of course ordered the files according to date (in the name) in the specific folder, but the code does not acknowledge that at all. Can anyone help me - is there some order function in c# that I have missed?