Click here to Skip to main content
15,883,910 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Is there any way to know when a folder is opened? I mean, if I manually open a folder (whith explorer), may I get this folder path?

Thanks
Posted
Comments
TweakBird 23-Mar-11 15:01pm    
Did you noticed that explorer looks like a 'TreeView' control.
Toli Cuturicu 24-Mar-11 9:24am    
Don't post fake answers!

No. There is no such operation as "open folder", so there is nothing to detect. It is only a metaphor of the UI, unlike other folder operations.

You can detect any "essential" file system operations though using the class System.IO.FileSystemWatcher.

[EDIT] See another Answer to the follow-up Question posted below.

—SA
 
Share this answer
 
v2
Comments
JGonc19 23-Mar-11 15:22pm    
And what about get all the open folders when a double-click is done?
Sergey Alexandrovich Kryukov 23-Mar-11 16:34pm    
See my other Answer.
--SA
There is no such thing as an "open folder". When you see an "open folder" in Explorer, it's merely a visual representation used to show you ther files in that folder. You can't detect when someone clicks (or double-clicks) on a folder beyond combination of visual representation and event handling performed by your own code.
 
Share this answer
 
Answering the follow-up Question: how to get the open folder from Explorer?

You can locate Explorer's main windows using the class System.Diagnostics.Process. The property System.Diagnostics.Process.MainWindowTitle will give your the current open folder, see
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.mainwindowtitle.aspx[^].

But why? Explorer in just one of the many applications which can access file structure. There is too much bothering about identification of the instances of Explorer process, but what's the use? There is nothing special about this application. Running it makes no difference in the system. By the way, there is a number of alternative file managers, much better then Explorer. Whatever you do with the Explorer, I see no sense.

—SA
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 23-Mar-11 20:54pm    
My congratulations to the one who voted 1: idiot detected!
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900