Search code examples
.netwindowsfile-access

File is used by another process. How to know which process?


I keep getting that exception in my program. How do I know which process locked it, either by program code or by doing something with windows?

System.IO.IOException : The process cannot access the file 'file.ext' because it is being used by another process.


Solution

  • You can use ProcessExplorer to search for the file:

    Just run that (maybe you need to launch it with administrator rights), hit Ctrl-F and type in the name of the file which is locked - it will find all open handles which match the given name, and tell you which process it belongs to.