Why is a file not deleting?

When trying to delete a file in Windows and getting an error that the file cannot be deleted, there are a few common reasons why this can happen. Understanding the potential causes and solutions can help resolve file deletion problems.

The File is in Use by a Program

One of the most common reasons a file cannot be deleted is because it is still in use and open by a program. If a program has a file open, Windows will not allow it to be deleted. This prevents accidental deletion and data loss.

To fix this, close any programs that may be using the file. This includes applications like Microsoft Word with the file open, Windows Explorer browsing to the folder containing the file, etc. Once all applications using the file are closed, try deleting again.

You can use the Task Manager in Windows to help identify any applications still running that have the file open. Check both the Processes and Details tabs. End task on any unnecessary processes. Restarting your computer can also clear any locks on in-use files.

Determine What Program is Using the File

If you’re unsure what program still has the file open, you can use the Process Explorer tool from Microsoft’s Sysinternals suite. This will show you more details on file handles in use.

To use Process Explorer:

  1. Download and run Process Explorer (procexp.exe)
  2. Click Find > Find Handle or DLL
  3. Enter the full path to the locked file
  4. Process Explorer will highlight any processes with a lock on that file
  5. You can then end those processes accordingly

Process Explorer provides an easy way to identify what’s locking a file so you can troubleshoot why it cannot be deleted.

The File is in the Recycle Bin

If you have previously deleted a file and sent it to the Recycle Bin, trying to delete the original file again will result in an error. This is because the file still technically exists in the Recycle Bin folder.

To resolve this, first empty the Recycle Bin completely. This will remove any previous copies of the file you want to delete. After emptying the Recycle Bin, you should then be able to delete the file normally.

On Windows 10, you can empty the Recycle Bin by right-clicking it and selecting Empty Recycle Bin. Confirm deleting all items when prompted.

File Permissions are Preventing Deletion

The permissions set on a file via the NTFS file system also control whether you can delete a file. If your user account does not have the necessary permissions to delete the file, such as Write or Modify permissions, you’ll get errors trying to.

To check a file’s permissions:

  1. Right-click the file and select Properties
  2. Go to the Security tab
  3. Click Advanced

This will show you the current user and group permissions. Look for any Deny entries on your user account that block deletion access.

To fix, you need to modify the file permissions accordingly. Often this requires administrator access if you do not currently have permission. Contact your IT department for assistance adjusting file permissions to allow deletion if needed.

Take Ownership of the File

If you have administrative rights on your Windows computer, you can take ownership of the file yourself to modify permissions.

To take ownership:

  1. Right-click the file > Properties
  2. Go to the Security tab > Advanced
  3. Click Change at the top near owner name
  4. Enter your user account name to take ownership

Now that you are the owner, you can modify the permission entries for your user account to allow deletion as needed.

The File is Write Protected or Locked

If a file is marked as read-only, write protected, or locked, you will not be able to delete it until that protection is removed. Often applications will temporarily lock files in use as read-only as well.

To check for write protection:

  1. Right-click the file > Properties
  2. Uncheck Read-only if enabled under Attributes
  3. Click OK to remove read-only status

If the file is on removable media, such as an SD card, there may be a physical write protect lock switch. Sliding the switch to unlock should allow deletion.

Some applications and services like antivirus can also lock files until certain actions occur. You may need to whitelist the file or folder in your antivirus program then reboot to release the lock.

File Path is Too Long

Windows also has a maximum file path length of around 260 characters by default. If you attempt to delete files with longer paths, you’ll get errors that the file cannot be found or deleted.

To resolve this, the file needs to be moved to a folder structure with a shorter overall path length. You can also enable long file paths by adjusting the registry settings, but moving the file is the simpler solution.

Use directory names and nesting that keeps the total hierarchy under 260 characters if possible when creating new files and folders.

Drive Errors or File System Corruption

If a drive has errors or corrupt file system issues, you may receive errors trying to delete files on that volume. Hard drive problems that prevent properly reading or writing files will result in deletion failures.

It’s a good idea to run a chkdsk scan on the drive reporting file deletion issues. Chkdsk will check the drive’s file system integrity and repair any found problems.

To run chkdsk in Windows:

  1. Open an elevated Command Prompt
  2. Run “chkdsk X: /f” where X is the drive letter
  3. Restart your PC to allow chkdsk to scan on reboot

Chkdsk requires an unmounted drive to perform a full scan, hence needing to schedule it for reboot. After chkdsk repairs any corruption, file deletion should be enabled again.

If chkdsk is unable to fix the errors, or the drive has developed bad sectors, replacement of the hard disk may be required. Contact your IT department or a data recovery specialist for assistance in that scenario.

Anti-Virus or Ransomware Protection

Antivirus software and ransomware protection tools will lock files open or prevent access to protect them from malicious alteration. This can inadvertently block normal file deletion as well.

Try whitelisting the locked file or folder in your antivirus or anti-ransomware application. This will exempt it from the restricted access those security programs put in place.

You may also need to temporarily disable real-time protection in the antivirus application to delete the file. Re-enable it after to restore security scanning. Contact your security vendor for guidance on whitelisting and access exclusions if needed.

Manual Deletion from the Command Line

If you cannot resolve what is blocking file deletion through the normal graphical interface, you can try deleting from an elevated Command Prompt window.

To manually delete a file from Command Prompt:

  1. Open Command Prompt as Administrator
  2. Type the command: del /f /s /q “C:\My Folder\file.txt”
  3. Change the path and file name appropriately
  4. Force options like /f remove read-only status

This will force deletion of the specified file, bypassing any permission or use restrictions. Be cautious deleting system files.

You can also use the Windows Subsystem for Linux (WSL) to delete files from your Linux command line. This can sometimes bypass file locks present in the Windows file system.

Restart in Safe Mode

Boot your PC into Safe Mode to remove any third party driver and application interference when deleting files. Safe Mode loads only the bare essential device drivers and services.

To boot into Safe Mode:

  1. Go to the Start Menu > Settings > Update & Security
  2. Click Recovery in the left menu
  3. Under Advanced startup, click Restart now
  4. Choose Troubleshoot > Advanced options > Startup Settings
  5. Click Restart
  6. After restarting, press 4 or F4 to boot into Safe Mode

Now try deleting the previously locked files. If successful in Safe Mode, a third party driver or software was likely the cause.

Clean Boot for Driver Conflicts

You can also perform a Clean Boot in Windows 10 to isolate driver and startup program conflicts when deleting files.

To Clean Boot:

  1. Open msconfig (Start Menu > type msconfig > enter)
  2. Go to the Services tab and check Hide all Microsoft services
  3. Uncheck the remaining third party services
  4. Go to the Startup tab and open Task Manager
  5. Disable all startup items here
  6. Save changes and restart computer

Test deleting the file after booting. If successful, enable services and startup items selectively until you isolate the problematic program.


Troubleshooting and resolving file deletion errors involves checking for:

  • Programs using the file
  • File permissions
  • Read-only status
  • Drive errors
  • Antivirus interference

Using built-in tools like Process Explorer and Chkdsk can help identify and repair these issues. Forcing deletion through Command Prompt or Safe Mode may also bypass stubborn errors when deleting files in Windows.

Following file deletion best practices like closing applications using a file, organizing reasonable path lengths, and maintaining drive health will help avoid problems deleting files. Contact your IT help desk or a data recovery specialist if you exhaust all manual troubleshooting methods.