How to detect the sorting order of files in a folder using C#

316 views Asked by At

I know how to get files/enumerate files from a directory. I also know how to sort them with an arbitrary sorting order using DirectoryInfo.getFileSystemInfos and Linq queries. The problem is I want to detect the actual sorting order in the directory (set with File Explorer), so that I can use that specific sorting order to sort my own getFileSystemInfos list. I have tried using DirectoryInfo.enumerateFileInfos, DirectoryInfo.enumerateFiles, DirectoryInfo.getFileInfos and DireectoryInfo.getFiles. But all of them return files in alphabetical order and there is no overload for detecting and using the same sorting order as File Explorer for that particular folder. If I am privy to that sorting order, I can use Linq queries to reorder(if necessary) my list to match.

0

There are 0 answers