process file handles

Arkette

Well-known member
Joined
Apr 20, 2006
Messages
50
Location
Europe
Programming Experience
10+
This may well be a tricky one. Does anyone have any ideas, about how to get a list of files that have been locked by other processes. Drilling down through MSDN, I have found some classes that lead me to believe that there must be a way, but as per normal MSDN is somewhat opaque in it's documentation. So I thought, perhaps someone has already been this route and can save me some time.
 
I take it that you couldn't find it or did you froget? If you do have something I would be really grateful.
 
I did a little research on this for my own project and haven't had much luck... the closest thing I found was to simply create a filestream object and to try to open the file with read / lock and if it fails catch the exception. Other things could cause a failure, like privilege access problems, but if you inspect the specific exception that is thrown you should be able to confirm that it is related to the inability to lock the file.

I am not crazy about this solution but haven't found anything else... if anyone has something better I would love to know it!
 
Since I posted I have continue to research this topic and found that it is pretty much a non starter. For a time I held out some hopes for the system.diagnostics.process class, but the best thing that has to offer is a handle count, there is no collection of handles available to inspect. I then moved onto the possiblity of creating a a wrapper for a win32 api call, so I started reasearching the win32 api only to find that there was no help top be had there either. I finally discovered that this information can only be gleaned from undocumented calls to the "NT native api" - something I didn't even know existed till now. Since ultimately I needed to know the PID for the process that has locked a file, m ogden's solution doesn't work for me. I have to abandon this topic for now but I may well come back to it one day. If I ever get the working solution, I'll certainly post back.
 
Help.

Good Day,

I am new to these forums.

I need an answer to the question above as well, it would be very helpful.

Could anyone please help?
 
Back
Top