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, programmatically (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.