tags:

views:

155

answers:

1

Is there a way to get the PID from a process that is blocking a file using C#?

+4  A: 

I don't know whether it can be done entirely within the framework, but maybe you could call out to SysInternals' Handle.exe to do the heavy lifting here?

ZombieSheep
+1 for using Handle.exe. It would be very difficult to implement such functionality in C#: http://stackoverflow.com/questions/177146/how-do-i-get-the-list-of-open-file-handles-by-process-in-c
Darin Dimitrov
Thanks for the link, @Darin. Interesting!
Cerebrus
Parsing handle output can be a simple and clean choice.Thanks :).
Ricardo