Using C#, how does one figure out what process locked a file?

前端 未结 9 2070
死守一世寂寞
死守一世寂寞 2020-11-22 13:03

In Windows, how do I determine (using C#) what process locked a file?

Third-party tools are helpful, but not what I\'m looking for.

9条回答
  •  迷失自我
    2020-11-22 13:30

    You absolutely don't need to run in Kernel mode (!!!)
    It's a Win32 FAQ since Windows 95 (!) (in C, Google groups, Win32) : read the handle table, from User mode of course, and get the PID from the File handle ...

提交回复
热议问题