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.
Asked
Active
Viewed 299 times
0
-
And what have you tried so far to achieve this? Please show your work first and then ask for community help. – uTeisT Aug 09 '16 at 08:34
-
1So basically you want to know where Windows Explorer saves the sort order it has been configured to use for a specific folder so that you can read that information and perform the same type of sort? – Lasse V. Karlsen Aug 09 '16 at 08:34
-
But File Explorer does not show you the cardinal ordering of these files. File Explorer can be configured to show files sorted by any of the file metadata fields. Step back from what you think the requirement is - what is it you're actually trying to achieve? – Matt Aug 09 '16 at 08:34
-
1It's even possible that, at the time your program is running, the user has two explorer windows open at the same location but using different sort orders. "The" explorer sort order isn't necessarily well defined. – Damien_The_Unbeliever Aug 09 '16 at 08:40
-
@LasseV.Karlsen, That's specifically what I want to do – codebro Aug 09 '16 at 20:02
-
@Matt, I'm trying to read the images in a folder and display them in some kind of list. But I want to maintain the order that the user is seeing from his File Explorer window – codebro Aug 09 '16 at 20:06
-
Indeed, @Damien_The_Unbeliever. I want to detect the sorting order for a particular folder. I am willing to vary my sorting order to match that of File Explorer's for each folder. – codebro Aug 09 '16 at 20:10
-
@uteist, 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. – codebro Aug 09 '16 at 20:22
-
I'll give you a hint then. You need a shell extension and even with that you can only detect it for 1 open window. – uTeisT Aug 09 '16 at 20:54
-
The point is that you can't reliably say what sorting order "the" Explorer window is showing, because there could be two explorer windows showing, one sorting by date and the other sorting by file name. Which to choose? – Jim Mischel Aug 10 '16 at 01:47
-
@uteist, please, how does that work? – codebro Aug 10 '16 at 04:49
-
@JimMischel, in such case, I am looking for the sorting order for the particular path in the argv parameter. Since my app will need a file as argument. Like, when you open a video (from File Explorer) with a video player, the video player application will receive the video file's path in its argv parameter – codebro Aug 10 '16 at 04:59