So I was messing around with some Android files in my Windows 10 computer and was using Cygwin to run some commands. Later on when I wanted to delete some folders, Windows refused to delete them giving “Error 0x80070091: The directory is not empty”. I checked the user ownership to the folder and I had all the permissions, but still it refused to delete the folder. Finally, I figured out the reason behind this deadlock – the chmod command from Cygwin had changed the folder permissions. So the only solution is to revert the permissions back using the same chmod command.
Here are a few things you can do to fix the error 0x80070091 in Windows 10:
1. Check the disk for errors
- Open the File Explorer, right-click on the disk on which you are experiencing this error when deleting the files and select Properties.
- In the disk properties window, select the Tools tab and then click on Check button under the Error checking section.
- Start the disk checking by clicking on the Scan drive and let it finish. It may need to reboot your PC to finish the disk check.
- When the disk check has finished try deleting the folder/file in question again.
2. Change Ownership of the Folder/Files
- Press the Win+X hotkey and select Command Prompt (Admin) from the menu that appears.>
- Type the command Takeown /F FOLDERPATH /R /D Y in the command prompt where FOLDERPATH is the full path and name of the folder you want to change the ownership of. For example, if you want to change the ownership of E:\boot\rmdisk then type the following command:
takeown /F E:\boot\rmdisk /R /D Y
- Now try deleting the file or folder that was giving an error once again.
3. Use Cygwin to Change Folder/File Permissions
- Install Cygwin on your Windows PC. You can see instructions on https://www.cygwin.com/.
- Use the Cygwin Terminal and give the command chmod a=rwx folderpath where the folderpath is the full path and name of the folder you want to change the permissions of. For example, if you want to change permissions of E:\boot\rmdisk then type the following commands one per line:
chmod a=rwx ./boot/rmdisk
- Now try deleting the folder giving error once again.
Summary: There are many reasons for the error 0x80080091 in Windows. You can fix it by checking the file system for errors, taking the ownership for the folders or files in question or changing their access permissions using the Cygwin chmod command.