Solved

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

Posted on 2010-05-01
5
783 Views
Last Modified: 2013-12-17
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
Comment
Question by:YazArch
[X]
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
5 Comments
 
LVL 25

Expert Comment

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

Directory class members of no help.
0
 

Author Comment

by:YazArch
ID: 32543873
Thanks,

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

Accepted Solution

by:
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;
         
                    MessageBox.Show(view.SortColumns);
}
}
0

Featured Post

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

691 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