0

Trying to open a file i might get a error code 32 (sharing violation).

How can i figure out which process (e.g. process ID, or thread id) that is locking the file?

Bonus Reading

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
  • 1
    are you look for https://stackoverflow.com/a/47510579/6401656 ? – RbMm Apr 19 '21 at 22:13
  • [SysInternals Process Explorer](https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer) can show you which handles are open by which processes – Remy Lebeau Apr 19 '21 at 23:03
  • @RemyLebeau - yes, but in concrete case better use *FileProcessIdsUsingFileInformation* information for file. this is exactly show information for this concrete file – RbMm Apr 19 '21 at 23:11
  • 1
    Or using the Restart Manager. This is good: [How do I find out which process is locking a file using .NET?](https://stackoverflow.com/a/20623311/7444103) -- Mentioned and demonstrated in: [How do I find out which process has a file open?](https://devblogs.microsoft.com/oldnewthing/?p=8283) – Jimi Apr 19 '21 at 23:54
  • In all these cases, since this is a programming web-site, i need the *code* that can do it - not a tool. – Ian Boyd Apr 20 '21 at 13:21

0 Answers0