Sometimes a file or a directory gets locked and simply refuse to get deleted. This might happen due to several reasons. In most cases the file is in use by the operating system or by a program. Until the program relinquishes possession of the file, it cannot be deleted. Incorrect file permissions is another reason why a file may become difficult to delete. The file might be created by another user or might be marked read-only. Files with long filenames also tend to be difficult to delete.
When trying to delete such a file, Windows displays one of the following error messages:
- Cannot delete file: Access is denied.
- There has been a sharing violation.
- Make sure the disk is not full or write-protected and that the file is not currently in use.
- The source or destination file may be in use.
- The file is in use by another program or user.
The first three error message usually indicate errors in file permissions or file attributes. In this case, it’s possible to delete the file by taking ownership of the files or by making the correct changes to the file attributes.
In case of “file in use" errors, this is more difficult as you have to identify which process is using the file and then terminate the process to free the file from its grip.
The easier way out is to use a file deletion tool.
This is a simple program intended to delete and remove stubborn directories and files that cannot be removed by other means either because the path is too long, the name is invalid, or any of other errors that can be incurred upon file or directory deletion.
To delete a locked file, you can either right-click on the file in Windows Explorer and choose the “Delete with FilExile” option from the context menu. Or, you can open FilExile and from the simple interface click the Browse button to the open the file/browser selector dialog box.
Other features include:
- Safety features to prevent deletion of important directories
- Command-line Arguments
- Drag and Drop
FileASSASSIN is a program by Malwarebytes Corporation. To delete a file, you can drag any file onto the main window of the program or browse and pick the file that you want to delete. FileASSASSIN uses techniques such as unload modules, close remote handles, and terminate processes in order to remove the particular locked file. The user can decide which file processing methods they want the program to use. Even if you are unsure, you should check all the boxes – your goal is to delete the file, anyway.
You can also select the Windows delete on reboot method which would delete the file upon reboot.
This tiny program can close handle, unload DLL files, kill processes, delete files with invalid names, delete the index.dat file and can delete files with or without reboot. Unlocker not only deletes undeletable files but also tells you why the file cannot be deleted by normal procedure.
Simply right-click a file or folder which is locked, and select Unlocker from the context menu. You will see the processes or programs that are locking the file or folder. Then you can choose to kill or unlock the processes, with optional actions such as delete, rename, move or copy.
This is another resourceful program that lets you delete files and folders locked in by processes. You can access the program from its shortcut or from the Explorer context menu. Simply right-click on a file and choose “What’s locking this file?”.
LockHunter identifies the programs that is causing the lock-in. You then have the option to either manually terminate the process or allow LockHunter to do it for you. Other functions include unloading DLL files, renaming locked files, remove locking processes from hard drive. LockHunter deletes files into the recycle bin, so you may restore them if deleted by mistake.
Nice post.Another software alternative that works is "LongPathTool" for error messages: Cannot read from source file or disk, there has been a sharing violation, cannot delete file or folder, the file name you specified is not valid or too long, the source or destination file may be in use and many other file managing errors.