question

Nedudale-0390 avatar image
0 Votes"
Nedudale-0390 asked Nedudale-0390 commented

How can I get files the same order they are on the hard disk ?

I tried this two options :

 var images = System.IO.Directory.GetFiles(radarFolderImagesDownload,
                                   "*.gif", SearchOption.AllDirectories).OrderBy(x => x).ToArray();

 var sorted = Directory.GetFiles(radarFolderImagesDownload).OrderBy(f => f);


but the result in both cases is the same the files are not sorted as they are ordered on the hard disk :

The files have numbers and in images for example the order is 0,1,10....then 19,2,20,21...

145113-0110.jpg


And the order they are on the hard disk :

145114-0101.jpg


The problem is later if I want to play with timer the images on a pictureBox they will not be played in the same order as on the hard disk.


dotnet-csharpwindows-forms
0110.jpg (135.0 KiB)
0101.jpg (178.7 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Castorix31 avatar image
0 Votes"
Castorix31 answered Nedudale-0390 commented

Same question as how-can-i-get-files-from-the-hard-disk-as-array-in.html

(I posted the method used by Explorer, which sorts 0,1, 2, ...
karenpayneoregon posted another method that I did not test, but which seems to work too...


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I can't delete this one so I will accept the answer here too.

Accepted the answer in my older question. sorry.

0 Votes 0 ·