Fix "File Is Open in Another Program" in Windows 11
The Problem
Windows will not delete a file while a process holds an open handle to it. The dialog usually names the program, but often it names something unhelpful like "Windows Explorer" or nothing at all, because the process holding it is a thumbnail generator, an indexer, an antivirus scanner, or a sync client rather than the app you were using.
The fix is to identify what holds the handle and release it. Killing processes at random works occasionally and risks data loss; finding the actual holder takes about a minute.
Getting a permissions error instead of an in-use error? That is a different problem — see fix "you need permission to perform this action". Whole File Explorer hanging? See fix File Explorer crashing.
Symptoms
- "The action can't be completed because the file is open in another program."
- "The file is in use by Windows Explorer."
- A folder will not delete because "the folder or a file in it is open in another program".
- The file deletes but reappears, or the folder remains as an empty shell.
Step 1: Close the Obvious and Check the Preview Pane
Two Explorer features hold handles on files you have merely clicked.
- In File Explorer, go to View → Show and turn off Preview pane and Details pane.
- Switch the folder view from Extra large icons to Details — thumbnail generation keeps media files open.
- Close any app that opened the file, including minimised windows and anything in the system tray.
- Navigate out of the folder before deleting it. You cannot delete the folder you are currently viewing.
- Try the delete again.
Step 2: Find the Process Holding the File
Windows has this built in, and it names the process precisely.
- Press Ctrl + Shift + Esc to open Task Manager.
- Go to the Performance tab and click Open Resource Monitor at the bottom.
- In Resource Monitor, open the CPU tab.
- Expand Associated Handles, and type part of the file name into the Search Handles box.
- The results list every process holding it. Right-click the entry → End Process, or note the name and close that program properly.
Closing the program cleanly is always better than ending the process — ending a process discards unsaved work.
Step 3: Restart Windows Explorer
When the holder really is explorer.exe, restarting it releases everything at once.
- Open Task Manager → Processes.
- Find Windows Explorer, right-click → Restart.
- The taskbar and desktop disappear for a second and come back. Open windows in Explorer close; other apps are unaffected.
- Retry the delete.
- If Explorer will not come back: fix the taskbar not working or disappearing.
Step 4: Rule Out Sync Clients and Indexing
Background services are the most common invisible holders.
- OneDrive: click the cloud icon → ⋯ → Pause syncing → 2 hours, then retry. Files set to "Always keep on this device" are locked while syncing: fix OneDrive sync issues.
- Dropbox, Google Drive, iCloud: pause or quit the client the same way.
- Windows Search indexer: open Settings → Privacy & security → Searching Windows → Advanced indexing options → Modify, and untick the folder.
- Antivirus: a real-time scan holds a file for a few seconds after it changes. Wait, or add a temporary exclusion via Windows Security → Virus & threat protection → Manage settings → Exclusions.
Step 5: Delete from Terminal
Command-line deletion bypasses the shell's own handles.
- Right-click Start → Terminal (Admin).
- Delete a single file:
del /f "C:\Path\To\file.ext" - Delete a folder and everything inside it:
rmdir /s /q "C:\Path\To\Folder" - To get the exact path, right-click the file in Explorer → Copy as path, and paste it in — the quotation marks are included.
del /fstill fails on a locked handle, but it succeeds on the very common case where only the shell had the file open.
Take care with rmdir /s /q — it deletes the folder and all of its contents with no confirmation and does not use the Recycle Bin.
Step 6: Delete on the Next Restart
Some handles are only released when Windows restarts.
- Sign out and back in, or do a full restart — not Sleep, and not Fast Startup shutdown.
- Delete the file immediately after signing back in, before opening the folder that contains it.
- If Fast Startup keeps handles alive across shutdowns, turn it off: Control Panel → Power Options → Choose what the power buttons do → Change settings that are currently unavailable → untick Turn on fast startup.
Step 7: Delete It from Safe Mode
Safe Mode loads almost no third-party services, so nearly nothing can hold a handle.
- Boot into Safe Mode — full procedure: how to enter Safe Mode.
- Delete the file or folder normally.
- Restart into Windows.
- This resolves files locked by antivirus, backup agents, and virtualisation drivers.
Step 8: Handle a Path That Is Too Long or Has a Bad Name
Some files cannot be deleted because Explorer cannot address them.
- For a path over 260 characters, rename the parent folders to something short first, or delete from Terminal using the extended-path prefix:
del /f "\\?\C:\Very\Long\Path\file.ext" - For a file with a trailing space or a reserved name (
con,aux,nul,prn), use the same prefix form:del /f "\\?\C:\Path\To\bad name " - For a folder tree that will not clear, run:
rmdir /s /q "\\?\C:\Path\To\Folder"
Step 9: Check the File Is Not Damaged or the Drive Failing
A file that will not delete and throws I/O errors is a drive symptom, not a locking one.
- In Terminal (Admin):
chkdsk C: /scan - If it reports problems, schedule a repair pass:
chkdsk C: /f - Check drive health properly: check SSD and hard drive health.
- On an external drive: fix a corrupted USB or external drive.
What Not to Do
- Don't install an "unlocker" utility from a search result. Resource Monitor does the same job and is already on the PC; that category of download is a well-known adware carrier.
- Don't end
System,svchost.exe, orcsrss.exeto free a handle. You will crash or reboot the PC. - Don't force-delete files inside
C:\WindowsorProgram Filesbecause they will not go. If a program will not uninstall, use its uninstaller rather than deleting its folder.
Still Not Working?
If the file survives Safe Mode and Terminal, check whether it is a system-protected file — those are owned by TrustedInstaller and refuse deletion by design. Confirm you actually need it gone; if it is leftover from an uninstalled program, remove the program properly instead.
If you are trying to free space rather than remove one specific file, there are better targets: free up disk space when the C: drive is full and clean junk files.
Related: fix drag and drop not working and how to recover deleted files.
Related guides
How to Fix Drag and Drop Not Working in Windows 11
Cannot drag files in File Explorer or drop them onto the taskbar in Windows 11? Clear the stuck drag state, fix Explorer, and rule out the shell extensions behind it.
Fix "You Need Permission to Perform This Action"
Access denied when opening or deleting your own files in Windows 11? Take ownership, repair broken permissions, and fix folders inherited from an old PC or user account.
How to Fix File Explorer Crashing in Windows 11
File Explorer closes alone, hangs on This PC, or won't open folders? Restart Explorer, clear history, disable preview handlers, and fix shell extensions.
How to Fix Windows 11 Start Menu Not Opening
Start button dead or menu closes instantly? Restart Explorer, run Start troubleshooter, repair shell settings—no reinstall.
How to Fix Windows 11 Taskbar Not Working or Disappearing
Taskbar frozen, hidden, or icons won't click after an update? Un-hide the bar, restart Explorer, fix tablet mode, and reset shell settings.