If you have ever tried to delete a file, while it was still opened by a program, you probably received an error message to the effect of “Cannot delete file: Access is denied”. There are several other variations of this error, including:
- Cannot delete file: Access is denied
- There has been a sharing violation.
- The source or destination file may be in use.
- The file is in use by another program or user.
- Make sure the disk is not full or write-protected and that the file is not currently in use.
All of these mean the same thing. The file is in use by a program, and you can’t delete it until that program is closed. What do you do then when there aren’t any programs actually using the file?
Sometimes, a program (or even the Windows operating system) will fail to properly “let go” of a file it was using. The surefire way to get around the above errors is usually to restart your computer. This will force the offending program to close, and clear everything out of memory. When your computer restarts, you should be able to delete the file without a hitch.
Sometimes, rebooting is inconvenient or impossible. Other times, you want to know what specific program was causing the issue to begin with. In these situations, you can use Process Explorer  to help. Download  and run Process Explorer. If this is your first time using the program you will be prompted to accept the license agreement. Then:
- Click “Find” on the menu bar. Select “Find Handle or DLL”.
- In the window that opens, type the name of the file you are unable to delete.
- Press search.
- The results will list all the process that have that file open. Hopefully there are only a few.
- Double click on the first result. This will take you back to the main Process Explorer window. In the lower pane you will see the file you searched for listed.
- Right click on the file in the lower pane. And select “Close Handle”. Confirm the action if asked.
- Repeat steps 1-6 until the search return no more results.
You should now be able to delete the file without encountering an error message.