Click here to Skip to main content
13,258,055 members (48,120 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I need to check my folder's status...that is it opened or closed?
Posted 31-Dec-12 22:00pm
What do you think is "closed" and "opened"? :-)
Zoltán Zörgő 1-Jan-13 15:27pm
See update
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:[^]

But thsi should be the one you wanted.[^]

In every case make sure, you have elevated privileges!

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:[^]
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!

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
Zoltán Zörgő 1-Jan-13 5:03am
Thank you
prashant patil 4987 1-Jan-13 5:04am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171114.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100