process modifying/openning file
-
hi,can someone help me with this.... i want to know how to get the file name currently being modified/openned by certain process, i know about FileSystemWatcher tool but i want to get it in another way(i mean what process x is openning or modifying at a specific moment). is there any API or c# code to it??? any help is appreciated
-
hi,can someone help me with this.... i want to know how to get the file name currently being modified/openned by certain process, i know about FileSystemWatcher tool but i want to get it in another way(i mean what process x is openning or modifying at a specific moment). is there any API or c# code to it??? any help is appreciated
lost_in_code wrote:
i want to know how to get the file name currently being modified/openned by certain proc
Unless the process exposes some kind of ommunication mechanism, there's no way to tell.
lost_in_code wrote:
i know about FileSystemWatcher tool
The FSW won't work for you anyway since it can't tell that a file was opened at all. All it can see is the changes in the files timestamp attributes, which don't change if you open a file for read access.
lost_in_code wrote:
i want to get it in another way(i mean what process x is openning or modifying at a specific moment).
The only way I can think of would be to enumerate all the process handles, and all of the file handles in the system and start trying to match them up with each other. But, there is no way to tell an .EXE file from a .DLL file from a .TXT file from a .DOC file, or any other file type. On top of that, most apps out there don't hold files open when they load them, so there's no file handle to try and match up anyway. The bottom line is what you want to do is extremely difficult and unreliable.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008