Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I need to know all file which is opened by application on my system. E.x if notepad open C:\abc.txt then I should receive "C:\abc.txt" when querying. I need that because I want all files that are located on the file server must be close when user sleep the computer.

I think I can hook the Windows message that open the file. But it is not perfect because I can just catch the file which is open after my application runs. Even if I want to do it, then I still do not know what exactly the Windows message I should handle.

Do you know any solutions for this? Thanks a lot.
Posted

You should watch a directory instead of a file to detect this. Here's an example:

http://articles.techrepublic.com.com/5100-10878_11-6165137.html[^]
 
Share this answer
 
You could use the FileSystemWatcher object.

Here's a CodeProject example:
C#: Application to Watch a File or Directory using FileSystem Watcher[^]

Good luck!
 
Share this answer
 
I cannot use FileSystemWatcher because it can just catch Changed, Created, Deleted and Renamed events. If it can catch Open, Close events then it's ok.
Thanks for your reply.
 
Share this answer
 
Comments
Sauro Viti 22-Jul-10 5:43am    
Don't post comments as answer; use the "Add coment" link instead
Toli Cuturicu 22-Jul-10 10:00am    
Reason for my vote of 1
fake 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