.
Cannot Remove Folder, Directory is not empty. (SOLVED)
The error message "Cannot delete folder, directory is not empty" can be faced on any Windows based computer (Windows 10, 8, 7, Vista or XP) if you try to delete a folder that the system cannot access due to the permissions applied to it. In other cases the "Cannot Remove folder because the directory is not empty" issue, can be solved after scanning the hard disk for errors by using the "CHKDSK" command.
In this tutorial you will find detailed instructions on how to resolve the following errors while deleting a file or folder on Windows 10, 8, 7, Vista or XP:
- "Cannot remove Folder or File. The Directory is not Empty"
- "Folder Access Denied. You need permission to perform this action"
- "Cannot delete file. Cannot read from the source file or disk"
- "Cannot Remove Folder. Cannot find the specified file"
- Cannot Delete a File or Folder error in Windows.
HOW TO FIX: CANNOT REMOVE FOLDER OR FILE. THE DIRECTORY IS NOT EMPTY OR ACCESS IS DENIED
Method 1. Run CHKDSK on the drive.
The first step to resolve the ?Cannot remove folder" or "Cannot remove file" issue(s), is to perform a check disk scan on the disk, that contains the folder that we cannot delete.
1. Open an elevated command prompt (Command Prompt (Admin)).
2. In the command prompt window, type the following command and press Enter: *
- chkdsk c: /F /R
* Press the “Y” key if asked to check your disk the next time your system restarts.
3. After disk checking try to delete the problematic folder (or file). If you still cannot remove the folder, proceed to method-2.
Method 2. Modify Folder's (or File's) Permissions.
1. In Windows explorer, right click at the folder that you cannot delete and select Properties.
2. Select the Security tab and then click Advanced.
3. Click Change Owner
4. In the object name box type, type the name of the Administrator account (e.g. "User1" in this example) and then click OK.
5. Check the "Replace Owner on subcontainers and objects" checkbox and then click OK & OK again to close the security settings.
6. Now try to delete the folder (or the file) that you cannot delete. If you receive the same message, then proceed to method-3 below.
Method 3. Delete File or Folder from Command Prompt.
1. Open an elevated command prompt (Command Prompt (Admin)).
2. In elevated command prompt, give the below commands, according your case:
A. To delete a folder: *
- takeown /F "FolderName" /r /d y
- icacls "FolderName" /grant Username:F /t
- rd "FolderName" /S /Q
* Notes:
1. Replace the "FolderName" with the full path and the name of the folder that you cannot delete.
2. Replace the "Username" with the username of the Administrator account.e.g: if you want to delete the "Demo" folder (and its subfolders and files) under the "C:\Program Files\" directory and your Administrator account name is "User1", then the commands should be:
- takeown /F "C:\Program Files\Demo" /r /d y
- icacls "C:\Program Files\Demo" /grant User1:F /t
- rd "C:\Program Files\Demo" /S /Q
B. To delete a file: *
- takeown /F "Filename"
- icacls "Filename" /grant Username:F
- del "Filename"
* Notes:
1. Replace the "Filename" with the full path and the name of the file that you cannot delete.
2. Replace the "Username" with the username of the Administrator accounte.g. if you want to delete the "Example.doc" file under the "C:\Temp" directory and your Admin account name is User1, then the commands should be:
- takeown /F "C:\Temp\Example.doc"
- icacls "C:\Temp\Example.doc" /grant User1:F
- del "C:\Temp\Example.doc"
.
source:
https://www.repairwin.com/fix-cannot-remove-folder-directory-is-not-empty-solved/
No comments:
Post a Comment