Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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

Posted on 2010-05-01
Medium Priority
Last Modified: 2013-12-17

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?

Question by:YazArch
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 25

Expert Comment

ID: 32504506
Interesting requirement, but looks like there is no api of help now.

Directory class members of no help.

Author Comment

ID: 32543873

Interop.Shell32 has ShellFolderViewinterface which has ShellFolderViewClass which contains the SortColumns property, but how to retrieve that object from an Hwnd??

Accepted Solution

YazArch earned 0 total points
ID: 32585786
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;

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question