Have you ever been trapped in a frustrating loop on your Windows 11 PC, trying to delete or move a folder only to be met with the stubborn “The Directory Is Not Empty” Error 0X80070091? This cryptic message halts your workflow, leaving you staring at a seemingly empty folder you just can’t remove. You’re not alone. This error is a common, persistent headache for Windows users, stemming from hidden file conflicts and system glitches. In this comprehensive, 2000+ word guide, we’ll not only walk you through 10 proven fixes but dive deep into why this error happens, provide unique troubleshooting workflows, and give you the expert tools to prevent it from happening again.
Understanding the “Directory Is Not Empty” Error 0X80070091
Before we jump into solutions, let’s demystify the problem. The error code 0X80070091 is a system HRESULT code. In simpler terms, Windows is telling you, “I tried to perform your command (delete, rename, move), but my internal checks show data still exists in this location, so I’m refusing.”
Contrary to what you see, the folder is not truly empty. The culprit is almost always one of these invisible occupants:
- Hidden or System Files: Files like
desktop.iniorthumbs.dbthat are marked as hidden by the operating system. - Locked Files: A file within the directory is still in use by a process or application, even in the background.
- Path Length Issues: The total file path (directory + subfolders + filename) exceeds Windows’ traditional 260-character limit, causing command confusion.
- Corrupted File System Metadata: The Master File Table (MFT) on your drive has incorrect information about the folder’s contents.
- Permission Conflicts: Your user account lacks the specific permissions to view or delete certain protected files within the folder.
Understanding this is key. Our fixes will target each of these root causes systematically.
My Experience: As a system administrator, I’ve encountered this error everywhere from user profiles to software development directories. The most frequent culprit I’ve seen, especially after failed software uninstalls or interrupted file transfers, is a combination of locked hidden files and path length issues.
Important First Step: Preliminary Checks
Always start with these simple actions. They resolve the issue more often than you’d think.
- Close All Related Programs: Ensure no application is using a file from that folder. This includes File Explorer windows previewing content, media players, text editors, or even cloud storage apps like OneDrive.
- Restart Your Computer: A classic for a reason. A reboot clears system locks, refreshes processes, and can magically resolve the conflict.
- Run a Quick Malware Scan: Sometimes, malicious software can lock files to protect itself. Use Windows Security or a trusted third-party antivirus for a quick scan. Microsoft’s own documentation on securing your PC is a good reference point here.
If the error persists, it’s time for our structured, in-depth solutions.
Method 1: The Power User’s Fix – Command Prompt & PowerShell
This is the most effective and comprehensive method. We’ll use commands that can see and manipulate what the graphical interface cannot.
A. Using Command Prompt (Admin)
- Press Win + S, type
cmd, right-click “Command Prompt,” and select Run as administrator. - Navigate to the parent directory of the problematic folder. For example, if you can’t delete
C:StubbornFolder, you would type:cd C: - Now, run this critical command to delete the folder:
rmdir /s "StubbornFolder"- The
/sflag removes all subdirectories and files. - If it asks for confirmation, type
Yand press Enter.
- The
If that fails, use the nuclear option:
rmdir /s /q "StubbornFolder"
The /q enables “quiet mode,” forcing deletion without prompts. Use with caution.
B. Using Windows PowerShell (Admin) – Often More Powerful
PowerShell’s Remove-Item cmdlet is exceptionally robust.
- Press Win + X and choose Windows PowerShell (Admin) or Terminal (Admin).
- Use this command, replacing the path with yours:
Remove-Item -Path "C:FullPathToStubbornFolder" -Recurse -Force-Recurse: Deletes contents recursively.-Force: Ignores hidden, read-only files and confirmation prompts.
Expert Tip: If you suspect path length is the issue, PowerShell 5.1+ and modern apps can handle longer paths. However, for legacy compatibility, you can use the
\?prefix to bypass the limit:Remove-Item -Path "\?C:AVeryLongPath..." -Recurse -Force
Method 2: Unveiling the Hidden – Show & Delete Hidden Files
If a hidden file is the culprit, let’s make it visible and remove it.
- Open File Explorer and navigate to the problematic folder’s parent.
- Click the View menu → Show → Check Hidden items.
- Now open the stubborn folder. Do you see any faint icons (like
desktop.ini)? - Try deleting them first. If successful, you can then delete the main folder.
- If you can’t delete the hidden file, its attributes might be set. Go back to Command Prompt (Admin) in the parent directory and use:
attrib -h -s "StubbornFolder*" /s /dThis command removes Hidden (
-h) and System (-s) attributes from all files (*) in the directory and subdirectories (/s) including folders (/d). Then try deletion again.
Method 3: Diagnosing File Locks – Using Process Explorer (A Pro Tool)
This is my go-to method for tricky cases. Process Explorer from Microsoft’s Sysinternals suite is an invaluable, free tool that shows you exactly what is locking a file.


- Download Process Explorer from the official Microsoft Sysinternals website.
- Run it (Admin privileges help). Press Ctrl + F or go to Find → Find Handle or DLL.
- Type the name of the problematic folder or a file inside it.
- It will list every process holding a handle (lock) to that resource. You can then safely close that application via its interface or, if it’s a non-critical system process, end the process from within Process Explorer.
- Once the lock is released, immediately try deleting the folder.
Why this is unique: Most guides don’t mention this precise diagnostic tool. It transforms guesswork into a targeted solution.
Method 4: Leveraging Safe Mode
Booting into Safe Mode loads Windows with minimal drivers and startup programs, preventing most software from locking files.
- Go to Settings > System > Recovery.
- Under “Advanced startup,” click Restart now.
- After reboot, choose Troubleshoot > Advanced options > Startup Settings > Restart.
- Press 5 or F5 to enable Safe Mode with Networking.
- Log in and navigate to the folder. You should now be able to delete it.
- Restart normally to exit Safe Mode.
Method 5: Checking and Repairing Disk Errors
Corrupted file system metadata can cause this error. Let’s check the disk’s integrity.
- Open Command Prompt (Admin).
- Type the following command and press Enter:
chkdsk C: /f /r(Replace
C:with the correct drive letter.) - It will schedule a scan for the next reboot. Type
Yand restart your computer. - Allow the scan to complete (it can take a while). This scan attempts to repair bad sectors and fix file system errors that could be causing the “not empty” illusion.
Method 6: Taking Ownership and Adjusting Permissions
If permission conflicts are the barrier, you need to become the folder’s owner.
- Right-click the stubborn folder → Properties → Security tab → Advanced.
- Next to “Owner,” click Change.
- Type your username, click Check Names, then OK.
- Check the box “Replace owner on subcontainers and objects” → Apply → OK.
- Back in the Security tab, click Edit → Add → type your username → OK.
- Select your name, check Full control under “Allow,” click Apply, then OK.
- Now try deleting the folder.
Method 7: Utilizing Third-Party File Unlocker Software
For user-friendly alternatives, tools like LockHunter or IObit Unlocker can be effective. They integrate into your right-click menu, showing what’s locked and offering to unlock it. Only download such tools from their official, reputable websites to avoid malware.
Method 8: The Last Resort – When Nothing Else Works
If all else fails, these are your final options:
- Use a Live Linux USB: Boot from a Linux USB (like Ubuntu), mount your Windows drive, and delete the folder from there. Linux ignores Windows file locks and permissions, offering a clean slate.
- Perform a Clean Boot: This is less drastic than Safe Mode but helps identify if a startup service is causing the lock. Use
msconfigto disable all non-Microsoft services and startup items, then reboot and try deletion. - System Restore: If the folder appeared after a recent system change, reverting to a restore point from before the error might remove it.
Prevention: How to Avoid Error 0X80070091 in the Future
- Use Robust Uninstallers: When removing software, use dedicated uninstaller tools (like Revo Uninstaller) or the app’s own cleanup utility to remove all residual files.
- Manage Path Lengths: As a developer or power user, be mindful of deep nested folder structures. You can enable the “Enable Win32 long paths” policy in Windows 11 (Group Policy Editor or Registry) for modern apps.
- Close Programs Before File Operations: Always ensure files are not open in any application before moving or deleting their parent folder.
- Regular Maintenance: Periodically run
chkdskandsfc /scannow(System File Checker) to maintain file system health.
FAQs (Frequently Asked Questions)
Q1: Is it safe to force delete a folder with these commands?
A: The rmdir /s /q and Remove-Item -Force commands are safe for user data folders. However, never force delete critical system folders (like anything in C:Windows or C:Program Files) as it can destabilize your OS.
Q2: Could this error indicate a failing hard drive?
A: Potentially, yes. Persistent file system errors that aren’t resolved by chkdsk can be a symptom of a failing drive. Monitor your drive’s health using its manufacturer’s tools or Windows’ WMIC command (wmic diskdrive get status).
Q3: I get this error with OneDrive/Google Drive folders. What should I do?
A: This is extremely common. First, pause syncing for the cloud service from its system tray icon. Then, try the deletion. The sync process often locks files. After deletion, you can resume syncing.
Q4: What’s the difference between rmdir and del in Command Prompt?
A: rmdir (or rd) is for removing directories/folders. del is for deleting files within a directory. Using rmdir /s is the correct command for a non-empty folder.
Conclusion
The “The Directory Is Not Empty” Error 0X80070091 on Windows 11 is a solvable puzzle. By understanding its causes—hidden files, process locks, and permissions—and applying our structured guide, you can reclaim control over your file system. Start with the simple checks, escalate to Command Prompt/PowerShell fixes (Methods 1 & 2), and use advanced diagnostics like Process Explorer (Method 3) for stubborn cases.
By following these steps, you’re not just applying fixes; you’re building deeper troubleshooting expertise for your Windows system. Remember, the key is a methodical approach. One of these solutions will be the key that unlocks your stuck directory.


