Thursday, July 11, 2013

Process holding a file - Process Explorer and more

Its always annoying when we try to delete a file but find out that some process is holding that file which makes the deletion not possible. I have seen a lot of people restarting the PC to kill the process and then try to delete the file.

Process Explorer can come in very handy in identifying the process that is holding a particular file. The Process Explorer will also be useful in identifying the handles and DLLs processes that are opened. 

Downloading and installing the tool is very simple and can be done here. Once you open the Process Explorer, you will find all the processes that are currently running in the machine.
Process Explorer v15.31

If you need to find the process that is holding a file, goto Find -> Find Handle or DLL -> type the entire path of the file and hit search, the tool tell you the process that is preventing the file from deleting.

The Process Explorer displays various other information like, CPU, memory usage and I/O statistic. This can be compared to the task manager with exclusive sophistication.

Trying to delete a file from a piece of code will also encounter such problems and the process explorer could not be used in this situation. We need to kill the process that is holding the file and then try to delete the file.

   
Kill Process that is holding the file


This is the piece of code that can used to kill the process that is folding the file, <fileName>





No comments:

Post a Comment