When Windows says a file is "in use," it means a background program or Windows itself currently has a lock on it. To delete it, you have to release that lock first.
Here are the best methods to do this, ordered from quickest to most thorough.
Method 1: Find and close the locking program (Built-in)
You can use Windows' built-in Resource Monitor to see exactly which program is holding the file hostage.
1.Press the Windows key, type Resource Monitor, and open it.
2.Click the CPU tab at the top.
3.Click the Associated Handles bar to expand it.
4.Type the name of the stubborn file into the Search Handles box.
5.Wait a few seconds for the list to populate. You will see the process (program) using the file under the Image column.
6.Right-click that process and select End Process. (Warning: Be careful not to end critical Windows processes like svchost.exe or system, as this can crash your PC).
7.Try deleting the file again.
Method 2: Restart Windows Explorer
Often, File Explorer itself is the culprit—especially with PDFs, images, or videos—because it is trying to generate a thumbnail or preview.
1.Press Ctrl + Shift + Esc to open Task Manager.
2.If you are in the simplified view, click More details at the bottom.
3.Under the Processes tab, scroll down to find Windows Explorer.
4.Right-click it and select Restart. (Your taskbar and desktop icons will briefly disappear and reload.)
5.Try deleting the file again. (Tip: If you have the Preview Pane turned on in File Explorer, turn it off before trying to delete the file.)
Method 3: Use Microsoft PowerToys (Best for frequent issues)
If this happens to you often, Microsoft makes a free, official utility suite called PowerToys that includes a tool specifically for this called File Locksmith.
1.Install Microsoft PowerToys from the Microsoft Store.
2.Open PowerToys and make sure File Locksmith is toggled on.
3.Right-click the file you can't delete and select Unlock with File Locksmith (on Windows 11, you may need to click Show more options first).
4.A window will pop up showing every program using the file, with an End task button right next to each one. Close them, then delete the file.
Method 4: Delete it in Safe Mode (Best for stubborn files)
If a background service keeps locking the file immediately after you restart your PC, booting into Safe Mode prevents third-party apps and non-essential services from starting.
1.Open the Start Menu, hold down the Shift key, and click Power > Restart.
2.On the blue screen that appears, select Troubleshoot > Advanced options > Startup Settings > Restart.
3.When your PC restarts, press 4 (or F4) to boot into Safe Mode.
4.Navigate to the file and delete it normally.
5.Restart your computer to return to normal Windows.
Method 5: Force-delete via Command Prompt
If the file isn't actually locked by a third-party app, but File Explorer is glitching out (common with corrupted files or long file paths), Command Prompt can sometimes bypass it.
1.Close all File Explorer windows.
2.Press the Windows key, type cmd, right-click Command Prompt, and select Run as administrator.
3.Type the following command and press Enter (replace the text in quotes with the actual path to your file):
del /f "C:\path\to\your\file.ext"
(If it is a folder, use rmdir /s /q "C:\path\to\your\folder" instead.)
Note: Always double-check what a file is before force-deleting it. If the file is located inside C:\Windows or C:\Program Files, it may be locked because Windows or an installed program actively needs it to function.