How to get files from directory in same order as in windows explorer? [duplicate]
Possible Duplicate:
Natural Sort Order in C#
how can I read the files from a directory in the same order as displayed in the windows explorer?
For example, the windows explorer lists:
file 1.txt
file 2.txt
file 3.txt
file 4.txt
file 5.txt
file 6.txt
file 7.txt
file 8.txt
file 9.txt
file 10.txt
file 11.txt
file 12.txt
while Directory.GetFiles() lists:
file 1.txt
file 10.开发者_高级运维txt
file 11.txt
file 12.txt
file 2.txt
file 3.txt
file 4.txt
file 5.txt
file 6.txt
file 7.txt
file 8.txt
file 9.txt
[EDIT]
Here you can find another solution for this: http://www.codeproject.com/KB/recipes/csnsort.aspx?msg=3342284
That special ordering was a new feature added in WinXP. Your best bet would be to re-implement the same sorting algorithm (see the link above for how to do it) on the collection once you've loaded the collection using Directory.GetFiles()
.
精彩评论