I'm trying to obtaint a sorted list of the files inside a directory. This files have differentes extensions.
foreach (String File in Directory.GetFiles(directory, "*").OrderBy(f => f))
{
stringA[i] = File;
i++;
}
The problem is that the result is not sorted like I expected. This is what I obtein in "stringA":
1.txt
10.txt
11.png
12.png
18.png
19.txt
2.txt
21.png
22.png
23.png
24.png
25.txt
26.txt
27.txt
28.txt
29.txt
3.png
30.txt
31.txt
32..png
33..png
34..png
35.png
4.txt
40.txt
41.png etc
What I want is : 1.txt, 2.txt, 3.png, 4.txt, 5.png, 6.txt, 7, 8, 9, 10 , 11, 19, 20, 21, 29, 30...
What can I do?
javac#or any one else ??