Sometimes, for whatever reason, Windows will become convinced a given file is in use by a program and prevent it from being deleted, moved or renamed. This locking up of files is incredibly frustrating, especially when you know the file is not, in fact, being used. Here are two ways to get around that issue.
1. Force delete using Windows
First, open the command prompt. To do this, start by opening the Start menu (Windows key), typing
run, and hitting Enter. In the dialogue that appears, type
cmd and hit Enter again.
With the command prompt open, enter
del /f filename, where
filename is the name of the file or files (you can specify multiple files using commas) you want to delete. There are more details on advanced deletion methods here.
Note that to delete the file you’ll need to either include the full path of the file where you replace
filename, or navigate to the folder it is contained in using
cd folderpath, and then run the
del command. See the image below for an example of the latter method.
2. Use Unlocker
Unlocker is a free program that simplifies the deletion of locked files. It adds a context menu item to Windows Explorer, and can be activated by right-clicking. It also allows the user to rename or move a locked file.
There you have it, two simple methods for fixing a stubborn issue!
Jump Start Git, 2nd Edition
Visual Studio Code: End-to-End Editing and Debugging Tools for Web Developers