Fix "File Is Open in Another Program" in Windows 11

Windows 11FilesTroubleshootingFixShell

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.

  1. In File Explorer, go to ViewShow and turn off Preview pane and Details pane.
  2. Switch the folder view from Extra large icons to Details — thumbnail generation keeps media files open.
  3. Close any app that opened the file, including minimised windows and anything in the system tray.
  4. Navigate out of the folder before deleting it. You cannot delete the folder you are currently viewing.
  5. Try the delete again.

Step 2: Find the Process Holding the File

Windows has this built in, and it names the process precisely.

  1. Press Ctrl + Shift + Esc to open Task Manager.
  2. Go to the Performance tab and click Open Resource Monitor at the bottom.
  3. In Resource Monitor, open the CPU tab.
  4. Expand Associated Handles, and type part of the file name into the Search Handles box.
  5. 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.

  1. Open Task ManagerProcesses.
  2. Find Windows Explorer, right-click → Restart.
  3. The taskbar and desktop disappear for a second and come back. Open windows in Explorer close; other apps are unaffected.
  4. Retry the delete.
  5. 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.

  1. OneDrive: click the cloud icon → Pause syncing2 hours, then retry. Files set to "Always keep on this device" are locked while syncing: fix OneDrive sync issues.
  2. Dropbox, Google Drive, iCloud: pause or quit the client the same way.
  3. Windows Search indexer: open SettingsPrivacy & securitySearching WindowsAdvanced indexing optionsModify, and untick the folder.
  4. Antivirus: a real-time scan holds a file for a few seconds after it changes. Wait, or add a temporary exclusion via Windows SecurityVirus & threat protectionManage settingsExclusions.

Step 5: Delete from Terminal

Command-line deletion bypasses the shell's own handles.

  1. Right-click StartTerminal (Admin).
  2. Delete a single file:
    del /f "C:\Path\To\file.ext"
    
  3. Delete a folder and everything inside it:
    rmdir /s /q "C:\Path\To\Folder"
    
  4. To get the exact path, right-click the file in Explorer → Copy as path, and paste it in — the quotation marks are included.
  5. del /f still 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.

  1. Sign out and back in, or do a full restart — not Sleep, and not Fast Startup shutdown.
  2. Delete the file immediately after signing back in, before opening the folder that contains it.
  3. If Fast Startup keeps handles alive across shutdowns, turn it off: Control PanelPower OptionsChoose what the power buttons doChange 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.

  1. Boot into Safe Mode — full procedure: how to enter Safe Mode.
  2. Delete the file or folder normally.
  3. Restart into Windows.
  4. 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.

  1. 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"
    
  2. 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 "
    
  3. 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.

  1. In Terminal (Admin):
    chkdsk C: /scan
    
  2. If it reports problems, schedule a repair pass:
    chkdsk C: /f
    
  3. Check drive health properly: check SSD and hard drive health.
  4. 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, or csrss.exe to free a handle. You will crash or reboot the PC.
  • Don't force-delete files inside C:\Windows or Program Files because 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.