I have been working on a c# image viewer that will read images from my computer and show them in the program.
//foreach file in path display the filename
foreach (var filename in Directory.GetFiles(<path>))
{
MessageBox.show(filename);
}
//Get image by number
var image = Directory.GetFiles(<path>).elementatordefault(<picnumber>).tostring());
My problem is that even if my images are ranked in order in the folder: 1,2,3,4 .....12,13,14....101,102, my application will show the files in the following order: 1,101,102,12,13,2...
How would I show the images in the correct like they are in the folder of the pc? I can't believe I would need to add each file to an array or list and then preform a sorting algorithm... (I would also need to split the file path and extension)there must be a simpler way of doing this,any help would be much appreciated.