We’ve all been there – trying to delete a file, but getting an error saying “Cannot delete file” or “Access denied”. This can be incredibly frustrating, especially when it’s taking up precious hard drive space!
There are a few main reasons why you might encounter undeletable files:
File permissions
If you don’t have administrator or full control permissions over a file, you won’t be able to delete it. This is common in work environments where permissions are restricted for security reasons.
File in use
You cannot delete a file while it is open or being used by a program. The file must be closed first before deletion is possible. This applies to documents, media files, program files, etc.
System file
Certain files are protected system files that are necessary for Windows or other programs to run properly. Windows won’t easily let you delete critical system files.
Corrupted file
If a file is corrupted or damaged in some way, trying to delete it may result in errors. This is because the file system cannot properly interact with the corrupted data.
Pending writes
If a file has data that is waiting to be written or synced, it may lock the file to prevent corruption while writes are pending. Closing any associated programs may unlock the file.
removable drive
Trying to delete files on a removable drive like a USB flash drive or external hard drive that is write protected or corrupted can result in deletion errors.
The good news is there are methods you can use to force delete just about any file, even those that Windows and other programs block you from removing through typical methods.
Bypass File Permissions
If you get an “Access denied” error when trying to delete a file, it likely means you lack the admin or system permissions to manipulate the file.
Here are some ways to bypass permissions:
Take Ownership
In Windows, you can take ownership of files and folders you don’t have permissions for. To do this:
1. Right click the file/folder and select Properties
2. Go to the Security tab
3. Click Advanced
4. Click the Owner tab
5. Change the owner to your username
6. Apply the changes
Now that you are the owner, you can grant yourself full permission to delete the file.
Use Administrator Account
Log into an admin or elevated privileges account that has full control permissions. Then try deleting the file when signed in as the admin.
Unlocker Software
Tools like Unlocker can easily delete files and folders by bypassing Windows permissions. Simply right click a locked file, select Unlocker, and choose a deletion option.
Command Prompt
Open a Command Prompt window as Administrator. Then use the “DEL” command to force delete read-only files. For example:
DEL C:\MyFile.txt
This will override permissions and delete MyFile.txt
Close Programs Using the File
If a file is being used by a running program, it will be locked and undeletable. Here are some tips for closing the associated program:
Use Task Manager
Open Task Manager and go to the Processes tab. Look for any process or program that might be using the file. Select it and click End Process to force close the program so the file can be deleted.
Restart Computer
The simplest solution is to restart your computer, which closes all running programs and releases any locked files.
Close Command Prompt
If the file is open in Command Prompt, simply close the Command Prompt window. This releases the file so it can be deleted.
Exit Software
If you have a program open that is accessing the file, properly exit or quit the application first before attempting to delete. This includes apps like text editors, media players, Word/Excel, browsers, etc.
Delete System Files
To remove Windows system files and other protected operating system files, you’ll need to disable some safeguards.
Here are a few ways to delete protected system files:
Uncheck Read-only Attribute
Many system files have the read-only attribute checked which prevents deletion. Uncheck this box to remove restrictions.
1. Right click file > Properties
2. Uncheck Read-only > OK
3. Delete
Command Prompt
Use the Command Prompt DEL command with the /F switch to force delete read-only files:
DEL /F C:\SystemFile.sys
Unlocker Software
Once again, Unlocker is an easy utility for bypassing delete restrictions on system files.
Take Ownership
You may need to take ownership of system files first before you can delete them. See the previous permission bypass steps.
Repair Corrupted Files
If a file is corrupted, troubleshoot and repair it before attempting deletion. Here are some corruption fixes:
File Recovery Software
Specialized file recovery tools like Recuva and EaseUS Data Recovery Wizard can scan corrupted files and repair them.
SFC Scannow
Run the System File Checker to scan Windows system files and restore corrupted files:
1. Open Command Prompt as Admin
2. Type sfc /scannow
3. Restart your PC
CHKDSK
Use CHKDSK in Command Prompt to detect and repair file system errors:
chkdsk C: /f
Replace C: with the drive letter.
Format Drive
As a last resort, reformat the entire drive to factory settings to fix deep seated file corruption. Backup data first as formatting erases everything.
Disable Write Protection on Removable Drives
If you cannot delete files on a USB flash drive, SD card or external hard drive, it may be write protected. Here’s how to remove write protection:
Remove Physical Lock
Look for a tiny lock switch on the media. Sliding it will disable write protection.
Clear Attribute
Use Command Prompt to remove the read-only attribute on the drive:
attrib -r G: /s /d
Replace G: with the drive letter.
Reformat Drive
You may need to completely reformat the removable drive to overwrite write protection or corruption. Backup data first.
Force Delete with Unlocker Software
Unlocker is a free utility that can delete any file, locked or unlocked. It’s one of the easiest ways to force delete stubborn files.
To use Unlocker:
1. Right click the file and select Unlocker
2. Choose a deletion option like Delete or Permanently Delete
3. Click Yes to confirm
Unlocker overrides permissions and locks to mercilessly annihilate unwanted files.
Delete File Via Command Prompt
For advanced users, the Command Prompt offers a few powerful file deletion techniques.
Open Command Prompt as Administrator. Then:
DEL /F
DEL /F FILENAME
Deletes the file by force even if in use or locked.
DEL /S
DEL /S FOLDERNAME\*.*
Deletes all files in the folder and subfolders.
RD /S
RD /S FOLDERNAME
Deletes the folder and all its subfolders.
FORMAT
FORMAT G: /FS:NTFS
Formats an external drive G:. Replace letter.
These commands override normal delete restrictions for quick removal.
Reset File Permissions
If permission issues are preventing file deletion across your system, resetting the file permissions may help.
1. Boot into Safe Mode by restarting your PC and pressing F8.
2. Once in Safe Mode, run Command Prompt as Admin.
3. Type this command:
icacls * /grant Administrator:F /T /C /Q
This resets all files to give Admin full control.
Reboot and you should then be able to delete any file.
Delete File via Linux Live CD
You can bypass Windows file restrictions by booting from a Linux live CD/USB. This gives you full system access from outside Windows.
Steps:
1. Download Linux ISO image like Ubuntu
2. Create bootable CD or USB
3. Change BIOS boot order to boot from CD/USB
4. Launch Linux system
5. Access Windows drive and delete files
Linux ignores Windows locks and permissions for unfettered file deletion.
How to Find Files Taking Space
Before deleting files, you’ll want to know what’s taking up space on your drives. Here are some useful tips for finding space hogs:
Disk Cleanup
Run Disk Cleanup utility to find and delete system cache/tmp files, old Windows updates, etc.
Storage Sense
Windows 10 has a Storage Sense feature that analyzes and identifies rarely used files that can be deleted.
Folder Sizes
Use Explorer or third party tools to analyze folder sizes. This reveals which folders contain the most data.
Windirstat
WinDirStat is a free utility that visually maps file and folder sizes on your drives. It makes it easy to spot huge files.
SpaceSniffer
Like WinDirStat, SpaceSniffer maps a visual drive usage breakdown to highlight large space hogging files.
By finding your biggest files first, you can selectively delete data more effectively.
Securely Wiping Deleted Files
When deleting sensitive files like financial documents or system files, you may want to take precautions to prevent recovery.
Here are some tips for secure deletion:
Use Eraser Program
Eraser is a free secure deletion tool for Windows. It overwrites deleted files multiple times to prevent undeletion.
Wipe Free Space
Tools like Eraser or CCleaner can overwrite unused drive space to wipe any trace of previously deleted files.
Encryption
Encrypt sensitive files before deleting them. This scrambles the file data to make recovery impossible.
Destructive Hardware
Physically destroying drives and media ensures no file recovery is possible. But backup data first!
Drive Wipe Software
Darik’s Boot and Nuke (DBAN) can fully wipe a drive by overwriting data with zeros, ones or random data.
Recovering Deleted Files
If you accidentally deleted an important file, recovery software may be able to restore it:
Recuva
Recuva is a free deleted file recovery tool. It can undelete files on your hard drive or external media.
TestDisk
TestDisk can recover lost partitions as well as undeleting files on those partitions.
Photorec
PhotoRec is good for recovering image and media files like photos, videos and music files.
R-Studio
R-Studio offers advanced data recovery features like RAID recovery and has a deep scan mode.
EaseUS
EaseUS Data Recovery Wizard provides file recovery via an easy to use interface.
To improve your chances, recover files immediately after deletion, don’t write new data, and stop using the drive.
Prevention Tips
You can avoid problems deleting files by taking some preventative measures:
– Back up your data regularly in case you need to delete files and recover them later.
– Make sure you have admin rights on your user account to avoid permission issues.
– Close programs properly so they release file locks.
– Use the Safe Remove Hardware option before disconnecting storage media.
– When deleting batches of files, use SHIFT+DELETE to permanently wipe them instantly.
– Remove duplicated and unnecessary files regularly to free space.
– Encrypt sensitive files for security before deletion.
– Install anti-virus software to detect and remove malware that may lock files.
Taking simple precautions can prevent headaches if you need to mass delete files.
Conclusion
While undeletable files can be incredibly annoying, there are plenty of ways to force delete just about anything. Bypassing permissions, closing programs, unlocking files, wiping drives, and using powerful deletion tools are solutions for removing stubborn files. Just be cautious when deleting system files and be sure to back up important data first! With this comprehensive guide, you now have all the tools and knowledge needed to easily annihilate even the most uncooperative of files.