Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I need to check my folder's status...that is it opened or closed?
Posted
Comments
Sergey Alexandrovich Kryukov 1-Jan-13 3:56am    
What do you think is "closed" and "opened"? :-)
—SA
Zoltán Zörgő 1-Jan-13 15:27pm    
See update

It is not an easy task. Even less from c#.
You have to list all opened file handles, and search for the folder you want to monitor.
This is a VC tutorial: Listing Used Files[^]
You can run this command line application from your code, and parse the result: http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx[^]

But thsi should be the one you wanted. https://github.com/o2platform/O2.Platform.Scripts/blob/master/APIs/Windows/Win32/API_Win32Processes_Handles.cs[^]

In every case make sure, you have elevated privileges!

[Update]
Let's suppose this is not what you want. I have an other idea: since Windows Explorer and Internet Explorer have the same core, you have the possibility to list all opened instances of them and see what url's are open. And you can even distinguish between the two scenarios. See this short articla and sample code:
http://omegacoder.com/?p=63[^]
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 1-Jan-13 3:55am    
I voted 5, because this is useful and non-trivial information which may or may be useful for OP. Probably you miss just one thing: the question is very incorrect. I clarify it in my answer, please see. You answer is of course credited.

Happy New Year!

—SA
Zoltán Zörgő 1-Jan-13 5:01am    
Thank you! This was the only meaning I could give to the question. Actually there is an other. See update.
prashant patil 4987 1-Jan-13 4:07am    
+5
Zoltán Zörgő 1-Jan-13 5:03am    
Thank you
prashant patil 4987 1-Jan-13 5:04am    
welcome
A folder cannot be "opened" or "closed". This is nothing more then a metaphor. Nothing like that is an attribute of a folder. If you mean the a folder is shown is some file manager based on Shell (or not), this is a part of state of this manager, not the folder itself.

Solution one explains a very different thing: a file system object can have a handle currently used by some process. It's possible to find out which process holds which handles. This is needed if you need to find out what prevents some file system object from, for example, deletion. If this is what you need, go for it. But keep in mind that correct formulation of your questions is important. Besides, it's important to explain your ultimate goals when asking a question. This way, you get a chance to receive a good advice even if you have a misconception. As authors of majority of questions do have some misconceptions, knowing the goal is important.

—SA
 
Share this answer
 

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