Fix a file that will not delete
We'll close programs that have the file open, fix permissions, shorten long paths, and remove the file.
What you'll need
- Administrator or owner access (for permission fixes)
Step-by-step diagnostic
Quick triage — pick your path
Quick triage — pick your path
Choose the option that matches what you see. You can jump straight to that section.
- File in use or locked You see "file in use," "access denied," or "cannot delete."
- Permission denied You see "permission denied" or "access denied."
- Path too long (Windows) Error mentions path length or 260 characters.
- Follow full steps Work through the full procedure from closing programs to admin delete.
Show full guide
Steps
Goal: Close programs holding the file, fix permissions, shorten the path if needed, and delete the file.
- Close any program that has the file open. Use Resource Monitor (Windows) or lsof (macOS) to find it.
- Check that you have delete permission. Right-click > Properties > Security. Add your account or take ownership.
- Remove the read-only attribute if set.
- If the path exceeds 260 characters (Windows), move the file to a shorter path and delete from there.
- Use Command Prompt or Terminal with admin rights: del “filename” (Windows) or sudo rm “filename” (macOS).
- Good: The file is deleted. Bad: Still will not delete—restart or boot to Safe Mode.
Close programs
Goal: Release the file lock by closing the program that has it open.
- Windows: Open Resource Monitor (resmon.exe), CPU tab, search for the filename. End the process or close the app.
- macOS: In Terminal, run lsof | grep “filename” to find the process. Kill the process or quit the app.
- Try deleting again. You should see the file delete.
Check permissions
Goal: Ensure you have delete permission.
- Right-click the file > Properties > Security (Windows) or Get Info > Sharing & Permissions (macOS).
- Add your account with Modify or Full Control (Windows) or Read & Write (macOS). Or take ownership (Windows: Advanced > Owner).
- Uncheck Read-only if it is set. Try deleting again. You should see the file delete.
Shorten path
Goal: Work around the 260-character path limit on Windows.
- Move the file to a shorter path (e.g. C:\temp) using Explorer or robocopy.
- Delete the file from the short path.
- You should see the file delete.
Verification
- The file no longer appears in the folder.
- No “file in use” or “access denied” errors.
- Recycle Bin (Windows) or Trash (macOS) contains the file if you moved it there, or it is permanently removed.
When to get help
- File is on a network drive—check share permissions and that no one else has it open.
- System file—do not force-delete; you may break the system.
- Work computer—contact IT if you lack permission.
Escalation ladder
Work from the device outward. Stop when the problem is fixed.
- Close programs Close any app that has the file open. Use Resource Monitor or lsof to find it.
- Fix permissions Add your account or take ownership. Remove read-only if set.
- Shorten path Move file to shorter path if over 260 characters (Windows).
- Admin delete Use Command Prompt or Terminal with elevated rights.
- Restart or Safe Mode Restart the computer or boot to Safe Mode to release locks.
What to capture if you need help
Before calling support or posting for help, have these ready. It speeds everything up.
- Full path to the file
- Error message when deleting
- Whether any program has the file open
Do you see "file in use," "access denied," or "cannot delete"?
File in use or permission issues are the most common causes.
You can change your answer later.
Can you find and close the process?
Resource Monitor or lsof shows which process has the file.
You can change your answer later.
File deleted
Restart and try again
Does the error mention "path too long" or 260 characters?
Windows has a 260-character path limit.
You can change your answer later.
Move to short path and delete
Do you have delete permission?
Check Properties > Security. Add your account or take ownership if needed.
Reviewed by Blackbox Atlas
Frequently asked questions
- Why would a file not delete?
- Common causes: another program has it open, you lack delete permission, the path is too long (Windows), or the file is read-only. Close programs and check permissions first.
- How do I find what program has a file open?
- Windows: Resource Monitor (resmon) > CPU tab > search for the filename. macOS: lsof in Terminal. Close the program or restart the computer.
- What if the path is too long?
- Windows has a 260-character path limit. Move the file to a shorter path (e.g. C:\\temp) or use subst to map a drive letter to a parent folder, then delete from there.
Rate this guide
Was this helpful?
Thanks for your feedback.