• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 916
  • Last Modified:

How to get Files/folders Sort order in Windows Explorer window in C#?

Hello,

Is there a way to get the sort order for files and folders in a windows explorer window?

P.S: i can get the Hwnd, but how to get the sort order?

Thanks.
0
YazArch
Asked:
YazArch
  • 2
1 Solution
 
apeterCommented:
Interesting requirement, but looks like there is no api of help now.

Directory class members of no help.
0
 
YazArchAuthor Commented:
Thanks,

Interop.Shell32 has ShellFolderViewinterface which has ShellFolderViewClass which contains the SortColumns property, but how to retrieve that object from an Hwnd??
0
 
YazArchAuthor Commented:
Ok i figured it out:

//Shell32 is located in Interop.Shell32 assembly
 Shell32.ShellClass shell = new ShellClass();
   //Shellwindows is located in SHDocVw.dll under C:\windows
     ShellWindows shellWindows = (ShellWindows)shell.Windows();
         foreach (ShellBrowserWindow shellWindow in shellWindows)
            {                
     s = shellWindow.LocationURL; //this is the path

//This is the object that holds Explorer window information.
     ShellFolderView view = (ShellFolderView)shellWindow.Document;
         
                    MessageBox.Show(view.SortColumns);
}
}
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now