Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# .NET
I need to check my folder's status...that is it opened or closed?
Posted 31-Dec-12 21:00pm
Comments
Sergey Alexandrovich Kryukov at 1-Jan-13 3:56am
   
What do you think is "closed" and "opened"? :-)
—SA
Zoltán Zörgő at 1-Jan-13 15:27pm
   
See update
Rate this: bad
good
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: 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[^]
  Permalink  
v2
Comments
Sergey Alexandrovich Kryukov at 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ő at 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 at 1-Jan-13 4:07am
   
+5
Zoltán Zörgő at 1-Jan-13 5:03am
   
Thank you
prashant patil 4987 at 1-Jan-13 5:04am
   
welcome
Rate this: bad
good
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.
 
—SA
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 310
1 Sergey Alexandrovich Kryukov 192
2 PhilLenoir 164
3 Richard MacCutchan 160
4 Sharmanuj 146
0 Sergey Alexandrovich Kryukov 6,077
1 OriginalGriff 5,115
2 CPallini 2,473
3 Richard MacCutchan 1,597
4 Abhinav S 1,505


Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2014
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