What you see is an NTFS artifact. Other file systems (in particular, FAT or network file systems) may not show the same behavior.
If you need sorting, sort it yourself (perhaps make sure it is already in order, as this is probably a likely scenario).
For example, the following program:
using System; using System.IO; using System.Collections; public class Foo { public static void Main(string[] args) { string[] subdirectoryEntries = Directory.GetDirectories(@"j:\"); foreach (string d in subdirectoryEntries) { Console.WriteLine( d); } } }
Displays this output for my FAT formatted JAT disk:
j:\Qualcomm j:\Precor j:\EditPadPro j:\Qt
Also, even if NTFS sorts the entries in the directory, it may not sort them the way you want: Old New Thing - why do NTFS and Explorer disagree with sorting the file name?
source share