Files · Windows 11
Fix a file or folder that will not delete because it is open in another program
The 'open in another program' message means some process is holding the file open — often not the app you expect. Find the holder in Resource Monitor, close just that process or handle, and delete the file without a restart or a forced-delete tool.
What you need
- The file's exact name and location. You will search for it by name in Resource Monitor; a long name can be copied from the file's Properties.
- Your work saved in other apps. Closing the process that holds the file can close an app with it — save first, so that costs you nothing.
- No extra tools. Resource Monitor is built into Windows and names the holding process directly; nothing needs downloading.
Read the problem before you touch it
- The message is literal: a process has the file open. Windows will not delete a file that a running process holds open, and the dialog rarely names the process. The holder is often not the obvious app — a preview pane, a thumbnail generator, a backup or sync tool, or a crashed program that never let go.
- For folders, think contents, not the folder itself. A folder refuses to delete when anything inside it is open — including a Command Prompt or terminal window whose current directory is that folder, or an Explorer window previewing one of its files.
- Separate a live holder from a leftover one. If you closed the app an hour ago and the file is still locked, the process is either still running in the background or has hung. Task Manager's Processes list answers that in seconds: look for the app before assuming anything exotic.
The simple fixes, in order
- Close the obvious app — completely. Quit the program the file belongs to, including its system-tray icon, then try the delete again. Check Task Manager too: many apps minimize to the tray or leave a background process behind when their window closes.
- Restart Windows Explorer. Explorer itself holds files it is previewing or thumbnailing. In Task Manager, right-click Windows Explorer and choose Restart. The taskbar blinks and returns, any Explorer lock is released, and the delete often works immediately after.
- Find the holder in Resource Monitor. Open Resource Monitor (search the Start menu for it), go to the CPU tab, and expand Associated Handles. Type the file's name in that section's search box. The results name the exact process holding the file — this is the step that replaces all the guessing.
- Close that process and delete. If the holder is an app you recognize, close it normally. If it is a background process you can spare, right-click it in Resource Monitor and choose End Process — save other work first, since ending a process is abrupt. Then delete the file straight away, before anything opens it again.
The advanced route
- Close just the handle with Handle or Process Explorer. When the holding process is something you cannot stop — a service, or Windows itself — Microsoft's Sysinternals tools can close the single handle instead of the process. Handle lists which process has a file open from the command line, and Process Explorer can find and close a handle in its interface. Use this sparingly: closing a handle out from under a program can crash it or lose its data.
- Restart once, and delete before opening anything. A restart clears every handle, which is crude but decisive. Sign in, open nothing else, and delete the file first thing — before the app that keeps grabbing it has a chance to start. If a startup app re-locks it within seconds, disable that app in Task Manager's Startup tab for one restart.
- Delete from Safe Mode when a service always wins the race. If the holder is a service that starts before you can act, start in Safe Mode, where most third-party services and startup apps do not run, and delete the file there. Reserve this for files you are certain about — Safe Mode will happily delete things Windows normally protects you from touching.
End state
- The file or folder deletes normally, with no "open in another program" dialog.
- You can name the process that was holding it — and it is closed, restarted, or behaving now.
- Deleting other files in the same folder works too, so the lock is gone rather than moved.
When it goes wrong
- Resource Monitor shows the holder as System. Do not end the System process. That usually means a driver, an antivirus scan, or a network share has the file. Wait for a scan to finish, disconnect the share, or use the restart-and-delete-first route.
- The file deletes, then comes back. Something is recreating it — a sync folder re-downloading it, or an app regenerating a cache or log file. Pause the sync or stop the app's service first; a file that returns is being remade, not locked.
- The message appears for everything in a folder. One deeply buried file is locked, or a terminal window is sitting in that directory. Close terminals, change their directory to somewhere else, then search Resource Monitor for the folder's path instead of a single file name.
Related fixes
-
Fix Windows Update error 0x80070020
Error 0x80070020 means another program or process is holding a file the update needs, so the update cannot finish writing it. Close the holder first, restart the update services next, and use a clean restart to prove which background program was in the way.
-
Fix copy and paste that stops working until you sign out
Copy and paste failing mid-session — then working again after you sign out — almost always means the clipboard process has stalled or one app is holding the clipboard open. Restart the clipboard process first, find the app that breaks it next, and leave a full sign-out as the last resort, not the routine.
-
Fix a file that opens with the wrong app no matter how many times you set the default
A file that keeps opening in the wrong app after you have set the default more than once usually means the association itself is damaged or an app is resetting it. Set it by file type first, reset the offending app next, and rebuild the association only if it still will not stick.
-
Fix a folder that loads forever behind a green progress bar
One folder crawls behind a green progress bar while every other folder opens instantly. Explorer is scanning and classifying everything in it — usually because the folder is optimized for the wrong kind of file. Fix the folder's template first, then clear the caches that make the scan repeat.
Sources
- Microsoft Learn, Handle — listing which process has a file or directory open, by name.
- Microsoft Learn, Process Explorer — finding the process holding a handle and closing that handle.