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.

Category
Troubleshooting · Home maintenance
Time
5–15 min
Last reviewed
What you'll need
  • Administrator or owner access (for permission fixes)

Step-by-step diagnostic

Step 1 of 7
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.

  1. Close programs Close any app that has the file open. Use Resource Monitor or lsof to find it.
  2. Fix permissions Add your account or take ownership. Remove read-only if set.
  3. Shorten path Move file to shorter path if over 260 characters (Windows).
  4. Admin delete Use Command Prompt or Terminal with elevated rights.
  5. 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.

Close any program that might have the file open. Check Resource Monitor (Windows) or lsof (macOS) to find the process. Good: Process closed, file deletes. Bad: Still locked—check permissions.

You can change your answer later.

Can you find and close the process?

Resource Monitor or lsof shows which process has the file.

Windows: resmon > CPU tab > search for filename. macOS: lsof | grep "filename". Close the program. Good: File deletes. Bad: Cannot close or still locked—restart the computer.

You can change your answer later.

File deleted

The file has been deleted successfully.

Restart and try again

Restart the computer. Before opening any apps, try deleting the file. If it still will not delete, check permissions or path length.

Does the error mention "path too long" or 260 characters?

Windows has a 260-character path limit.

Move the file to a shorter path (e.g. C:\\temp) using robocopy or Explorer. Then delete from the short path. Good: File deletes. Bad: Different error—check permissions.

You can change your answer later.

Move to short path and delete

Move the file to C:\\temp or similar. Delete from there. Use robocopy /mov if needed.

Do you have delete permission?

Check Properties > Security. Add your account or take ownership if needed.

Right-click > Properties > Security. Add your account with Modify or Full Control. Or take ownership. Good: Permission fixed, file deletes. Bad: Contact IT or admin if on a managed system.

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.

Continue to