I have a folder which contains only .txt files. I want my output to have a certain order.
The first 2 digit of every filename is its unique ID. I want to order the files numerically in that order
I've researched multiple questions that seem similar to this like Getting all file names from a folder using C#
but none has helped me accomplish this goal. What is the easiest way for me to get my desired output?
string folder = @"C:\Testing\";
var txtFiles = Directory.GetFiles(folder, "*.txt")
.Select(Path.GetFileName)
.ToList();
foreach(var f in txtFiles)
{
Console.WriteLine(f);
}
Console.ReadKey();
Windows Explore
Console Output