Lỗi cannot delete file the directory is not empty

If you cannot delete a folder because of error 0x80070091 "The directory is not empty" continue reading below to fix the problem.

Problem in details: When you try to remove a folder, you get that "the folder is not empty", even if it is empty, with error:

1 Interrupted Action

A unexpected error is keeping you from deleting the folder. If you continue to receive this error, you can use the error code to search for help with this problem.

Error 0x80070091: The directory is not empty.

Lỗi cannot delete file the directory is not empty

The errors "directory is not empty", "cannot find the file specified", "cannot read from the source file or disk" & "you need permissions to delete a folder/fire", when trying to delete a file or folder, usually indicates a problem with the hard disk, or a permissions problem on the file/folder. To fix these problems, follow the methods below.

How to FIX Error 0x8007009. The directory is empty.

* Note: Before you continue to the methods below, see if you can delete the folder/file in Windows Safe Mode.

  1. Archive the Folder/File & Delete it.
  2. Modify Folder/File Owner & Delete it.
  3. Delete Folder/File with in Command Prompt.
  4. Check & Repair Disk.
  5. Delete Folder/File from WinRE.

Method 1. Fix "directory is not empty" by Compressing and Deleting the Folder/File.

The easiest method to remove a folder/file that cannot be deleted, is by compressing it to a archive with WinRAR or the 7-ZIP archiver and deleting it after the compression. To delete a file or folder that cannot be deleted with WinRAR:

  1. Download and install WinRAR (if you haven't already) and during installation choose to install the Legacy context menus.

Lỗi cannot delete file the directory is not empty

2. Right-click on the folder/file that you cannot remove and select 7-Zip > Add to archive.

Lỗi cannot delete file the directory is not empty

2. At Archive parameters, select to Delete files after archiving and click OK. Then, ask YES to confirm your decision.

Lỗi cannot delete file the directory is not empty

3. Normally the problematic folder/file will be deleted. Proceed to delete also the created WinRAR archive and you're done!

Lỗi cannot delete file the directory is not empty

Method 2. Modify the Owner of the Folder/File and Delete it.

Another method to resolve the issues mentioned in this post, is to change the owner of the folder or file you are having the problem with, and then delete it. To do that:

1. Right click at the folder or file that you cannot delete and select Properties. 2. Select the Security tab and click Advanced.

Lỗi cannot delete file the directory is not empty

3. Click Change Owner.

Lỗi cannot delete file the directory is not empty

4. Type your account username (e.g. "User2") and click OK.

Lỗi cannot delete file the directory is not empty

5. Check the "Replace owner on subcontainers and objects" checkbox and click Apply > OK. Then click OK again to close security settings.

Lỗi cannot delete file the directory is not empty

6. Now delete the problematic folder/file.

Method 3. Take Ownership and Delete the Folder/File from Command Prompt.

The next method to solve the problems "Cannot Delete File: The Directory is not empty", "Cannot find the file specified" and "You need permissions to delete the folder", is to change the ownership of the file or folder and then to delete it from Command Prompt.

To Delete a FOLDER that cannot be deleted with Command Prompt:

1. Open Command Prompt as Administrator. 2. Take the ownership permissions of the folder that you want to delete, by typing this command:

  • takeown /F "Full_Path_Folder_Name" /r /d y

* For example if you want to delete the folder "C:\Folder1", the command will be:

  • takeown /F "C:\Folder1" /r /d y

3. Then give this command to take full control permissions at the folder that you want to delete:

  • icacls "Full_Path_Folder_Name" /grant Administrators:F /t

* For this example the command will be:

  • icacls "C:\Folder1" /grant Administrators:F /t

4. Finally type the following command to delete the folder:

  • rd "Full_Path_Folder_Name" /S /Q

* For this example the command will be:

  • rd "C:\Folder1" /S /Q

Lỗi cannot delete file the directory is not empty

To Delete a FILE that cannot be delete with Command Prompt:

  1. In File Explorer Options uncheck the Hide extensions for known file types.

Lỗi cannot delete file the directory is not empty

  1. Notice the name of the file that you want to delete and its extension. (e.g. "File1.txt")

Lỗi cannot delete file the directory is not empty

3. Now, open Command Prompt as Administrator.

4. Take the ownership on the file that you want to delete, by typing this command:

  • takeown /F "Full_Path\Filename.extension"

* For example if you want to delete the file "C:\File1.txt", the command will be:

  • takeown /F "C:\File1.txt"

5. Then change the permissions on the file by giving this command:

  • icacls "Full_Path\Filename.extension" /grant YourUsername:F

* For example, if your Username is "User2" and want to change the permissions in file "C:\File1.txt", the command will be:

  • icacls "C:\File1.txt" /grant User2:F

6. Finally delete the file, with this command:

  • del "Full_Path\Filename.extension"

* For example, to delete the "C:\File1.txt" file, the command will be::

  • del "C:\File1.txt"

Lỗi cannot delete file the directory is not empty

Method 4. Check and Repair Disk.

The final method to fix the error 0x80070091 or to solve other problems when deleting a folder/file, is to check the hard disk for errors and to repair them, using the CHKDSK command. To do that:

1. Launch Command Prompt as Administrator.

2. In the command prompt, type the command below and press Enter.*

  • chkdsk X: /x /r

* Where X \= the drive letter of the disk with the problematic folder or file. For example, if the folder/file is located on disk "C", the command will be:

  • chkdsk C: /x /r

3. If you get the prompt to schedule the disk check the next time the system restarts. Press Y (to select Yes) and restart your device to scan and repair the disk errors.

Lỗi cannot delete file the directory is not empty

4. When restarting, let Windows complete the disk checking and repairing process and be patient as it will take a long time.

5. Finally, after entering to Windows proceed to delete the file/folder.

Method 5. Delete Folder/File from WinRE.

If you fail to delete a folder or file using the above methods, restart Windows in Windows Recovery Environment and delete the folder/file from there. To do that:

1. Hold down the SHIFT key on your keyboard and with your mouse go to Power > and click Restart.

Lỗi cannot delete file the directory is not empty

2. After restart, go to Troubleshoot > Advanced Options > Command Prompt.

Lỗi cannot delete file the directory is not empty

3. In command prompt type notepad and press Enter.

Lỗi cannot delete file the directory is not empty

4. From the File menu, select Open.

Lỗi cannot delete file the directory is not empty

5. Change the Files of type to All Files and then click This PC.

Lỗi cannot delete file the directory is not empty

6. Navigate to the location of the folder/file that you want to delete, right-click on it and choose Delete.

Lỗi cannot delete file the directory is not empty

7. Now, right-click on an empty space and choose Refresh to ensure that the folder/file is deleted.

Lỗi cannot delete file the directory is not empty

8. When done, close all windows and click Continue to Windows 10.

That's it! Which method worked for you? Let me know if this guide has helped you by leaving your comment about your experience. Please like and share this guide to help others.

If this article was useful for you, please consider supporting us by making a donation. Even $1 can a make a huge difference for us in our effort to continue to help others while keeping this site free:

Lỗi cannot delete file the directory is not empty

Konstantinos is the founder and administrator of Wintips.org. Since 1995 he works and provides IT support as a computer and network expert to individuals and large companies. He is specialized in solving problems related to Windows or other Microsoft products (Windows Server, Office, Microsoft 365, etc.).