Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 782
Louis Rhys Avatar asked Aug 02 '10 08:08

Louis Rhys


2 Answers

You can use ProcessExplorer to search for the file:

  • http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

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.

like image 111
Justin Avatar answered Sep 20 '22 04:09

Justin


You can use a tool like ProcessMon to see what process is locking a file.

like image 41
Oded Avatar answered Sep 23 '22 04:09

Oded