Get directories in order

Hi, so I’m using this: Directory.GetDirectories(“PATH”) to get all directories in a directory, but I’m not getting them in order. The name of the directories are : 001-xxxx, 002-xxxx … but I’m getting: 004-xxx, 002-xxx… In a different order each time.

will be something like this:
Dim di As DirectoryInfo = New DirectoryInfo(“C:”)
Dim files As FileSystemInfo() = di.GetFileSystemInfos()
Dim orderedFiles = files.OrderBy(Function(f) f.FullName)

but since you are only getting a string array with Directory.GetDirectories then you dont need the above :slight_smile:

Once you get the array of directories, next step you can sort the array Array.Sort(arr)

Ex:sortArray.xaml (6.0 KB)

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.