Encountering error code 0x80070091 can be frustrating, especially when you’re trying to delete a folder in Windows 10 or 11 and receive the message that the “Directory is not empty.” Fortunately, this issue is relatively common, and there are multiple solutions that can help resolve it. This error typically occurs when Windows believes the folder is still being used, is corrupt, or contains hidden or locked files.
This article provides a detailed guide on how to troubleshoot and fix the “Directory is not empty” error in Windows 10 and 11 using different methods. Whether you’re a beginner or an advanced user, you’ll find step-by-step instructions to help you resolve the problem efficiently.
Common Causes of Error 0x80070091
Before jumping into the solutions, it’s helpful to understand what could be causing the issue. Some common reasons include:
- File system corruption
- Ongoing background processes using the folder
- Folder permissions or ownership conflicts
- Hidden system files within the folder
- Malware or antivirus software interference
How to Fix the “Directory is Not Empty” Error
1. Restart Your Computer
Before trying any complex solutions, restart your computer. A reboot can often terminate background processes that may be using the directory, allowing you to delete it afterward.
2. Use Command Prompt to Force Deletion
Using the Command Prompt gives you more control over system operations. To delete a folder manually through CMD:
- Search for “Command Prompt” in the Start Menu.
- Right-click it and choose “Run as administrator.”
- In the Command Prompt window, type:
rd /s /q "C:\Path\To\Folder"
Replace C:\Path\To\Folder with the actual path of the folder you want to delete.
Note: This command will forcefully delete the folder and all its contents without prompting you for confirmation.
3. Check for Hidden Files
Sometimes hidden or system files prevent a directory from being recognized as empty.
- Open File Explorer and navigate to the folder in question.
- Click the View tab and enable “Hidden Items.”
- If you see any files appear, delete them before attempting to remove the folder again.
4. Use Safe Mode
Windows Safe Mode loads only essential system drivers and services, helping you delete folders that are otherwise in use.
To boot into Safe Mode:
- Press Win + R and type
msconfig, then press Enter. - Under the Boot tab, check “Safe boot” and select “Minimal.”
- Click OK and restart your computer.
- Try deleting the problematic folder again.
- After deletion, return to
msconfigand uncheck “Safe boot” to boot normally.
5. Use CHKDSK to Repair File System Errors
Corrupted file systems can cause deletion errors. Running CHKDSK can fix them:
- Open Command Prompt as Administrator.
- Type the following command:
chkdsk /f /r C: - If asked to schedule the scan on the next reboot, type
Yand press Enter. - Restart your PC and allow the scan to complete.
Once your system restarts, try to delete the folder again.
6. Scan for Malware
Some malware can prevent folders from being deleted. Use Windows Defender or a third-party antivirus to scan your PC.
- Open Windows Security from the Start Menu.
- Go to Virus & threat protection.
- Run a Full scan to detect and remove any malicious software.
After the scan, try to delete the folder once more.
7. Take Ownership of the Folder
Lack of ownership rights can block deletion attempts. To take ownership:
- Right-click the folder and select Properties.
- Go to the Security tab and click Advanced.
- Click Change next to Owner.
- Type your username, click Check Names, and then OK.
- Check “Replace owner on subcontainers and objects.”
- Click Apply and then OK.
8. Use a Third-Party Tool
If you’re still having trouble, third-party tools like Unlocker or UnlockIT can help remove stubborn files and folders.
These apps identify processes locking the directory and terminate them so you can proceed with deletion safely.
9. Restore Default Windows Permissions Using DISM
Corrupted permissions can sometimes cause the 0x80070091 error. Use DISM to restore system health:
- Open Command Prompt as Administrator.
- Type the following command:
DISM /Online /Cleanup-Image /RestoreHealth
Then press Enter. - Wait for the process to complete and then restart your PC.
10. Delete Folder via PowerShell
PowerShell offers another method to forcefully delete directories.
- Search for Windows PowerShell and run it as Administrator.
- Enter the following command:
Remove-Item -Path 'C:\Path\To\Folder' -Recurse -Force - Replace C:\Path\To\Folder with your target directory path.
Frequently Asked Questions (FAQ)
- Q: What does error 0x80070091 mean in Windows?
A: This code typically indicates that the directory is not empty, even if it appears so. It often results from hidden files, system corruption, or permission errors. - Q: Is it safe to delete folders using CMD or PowerShell?
A: Yes, as long as you’re sure about the path. Mistakes could lead to data loss, so double-check before executing commands. - Q: Why can’t I delete a folder even in Safe Mode?
A: If folder deletion fails even in Safe Mode, you might be dealing with disk corruption or malware. Use CHKDSK and antivirus scans to address deeper issues. - Q: What is the best third-party tool to fix folder deletion errors?
A: Reliable tools like Unlocker or IObit Unlocker are commonly used to remove locked folders and resolve error 0x80070091. - Q: Can I prevent this issue in the future?
A: Regular system maintenance, disk scans, and avoiding forceful shutdowns can help prevent file system errors that cause this problem.
By following the steps outlined above, users can effectively troubleshoot and resolve the “Directory is not empty” error in Windows 10 and 11. Always proceed cautiously, especially when using command-line tools or manipulating system files and permissions.