How to get the name of the process which locks a specfic file? [duplicate]
Possible Duplicates:
How does one figure out what process locked a file using c#? How do I find out which process is locking a file using .NET?
Hi,
i try to get the name of the process wich locks a file (not only a dll module, any file). For example if process "Process A" opens a file stream on "C:\temp\test.txt" this should be detected (if i try to delete the file in windows explorer it is locked till the process is killed).
There are several examples on Stackoverflow like: How does one figure out what process locked a file using c#?
Determine which process (b)locks a file, programma开发者_Go百科tically (under Windows >= XP)I tryed the examples above, but none of them works.
I also read somethink about the Win32 API function NtQuerySystemInformation, but i don't know how how to use it. Couldn't find any PInvoke code for it.
I use Process Explorer from SysInternals (It doesn't not require installation, it's a single exe).
- Ctrl+F (Find handle or dll)
- Type the name of the locked file
As already mentioned in the comment (by bzlm and Richard), handle.exe should work for you.
精彩评论