Error 0x80070091 “The directory is not empty”: how to fix it

Stack of folders, representing error 0x80070091 the directory is not empty in Windows

Quick answer: Error 0x80070091 means “The directory is not empty”: Windows tried to remove or replace a folder that still contains files. When you’re deleting or moving a folder, restart the PC, then delete it from Command Prompt with rd /s and run chkdsk /f on the drive if it still fails. When System Restore fails with 0x80070091 (usually mentioning AppxStaging or WindowsApps), run System Restore from Windows Recovery instead, and if that fails, rename the WindowsApps folder from the recovery Command Prompt and try again.

Applies to: Windows 11 and Windows 10, on internal drives, USB drives and memory cards.

Stack of folders, representing error 0x80070091 the directory is not empty in Windows

What error 0x80070091 means

0x80070091 is the Windows code for “The directory is not empty”. You’ll usually see it in one of two places:

Where you see itTypical messageGo to
Deleting, moving or renaming a folder in File ExplorerError 0x80070091: The directory is not empty.Fixes 1 to 4
System RestoreSystem Restore did not complete successfully, with an unspecified error 0x80070091 while restoring a directory (often AppxStaging)The two System Restore sections

With folders, the folder usually still holds hidden files, a file that’s in use, or damaged file system entries that Explorer can’t see. With System Restore, the restore point tries to put back Microsoft Store app files into C:\Program Files\WindowsApps while that folder is in use.

Fix 1: Restart and close anything using the folder

  1. Close any app, Command Prompt window or File Explorer window that has the folder or a file in it open.
  2. Restart the PC (use Restart, not Shut down, so Fast Startup doesn’t keep the old state).
  3. Try deleting or moving the folder again.

In File Explorer, turn on hidden items with View > Show > Hidden items (Windows 11) or the Hidden items box on the View tab (Windows 10). A folder that looks empty may still contain hidden files.

Fix 2: Delete the folder from Command Prompt

Command Prompt can remove a folder with all its contents, including hidden files, in one go. Make sure you have the right folder, because files deleted this way don’t go to the Recycle Bin.

  1. Open Command Prompt as administrator.
  2. Run the command below, replacing the path with your folder. Keep the quotes if the path has spaces.
  3. Type Y to confirm.
rd /s "D:\Old Photos\Folder name"

If rd says the folder is in use, change to a different folder first (for example cd C:\), since Windows can’t delete the folder Command Prompt is currently in. If it says access is denied, see you don’t currently have permission to access this folder to take ownership first.

To see what’s still inside, run dir /a "path", which lists hidden and system files too.

Fix 3: Check the drive with CHKDSK

Internal hard disk drive, representing running CHKDSK to fix error 0x80070091

If the folder can’t be deleted even from Command Prompt, the file system entries are probably damaged. This is common on USB drives and memory cards that were removed without ejecting. Run CHKDSK on the drive that holds the folder (replace D: with its letter):

chkdsk D: /f

For the Windows drive (C:), CHKDSK can’t lock the drive while Windows is running, so it asks to run at the next restart. Type Y and restart. When it finishes, try deleting the folder again.

If CHKDSK keeps finding errors, back up the drive’s files, because the drive may be failing.

Fix 4: Check OneDrive and antivirus

  • OneDrive: if the folder is inside OneDrive, files may be online-only placeholders that are still syncing. Pause syncing (OneDrive icon Settings > Pause syncing), delete the folder, then resume, or delete it on onedrive.com.
  • Antivirus: some security programs lock files while scanning them. Wait for the scan to finish, or exclude the folder temporarily. Don’t leave your antivirus off.
  • Safe Mode: if a program keeps locking the folder, start Windows in Safe Mode, where most third-party programs don’t load, and delete it there.

System Restore 0x80070091: run it from Windows Recovery

Laptop with a red screen, representing System Restore failing with error 0x80070091

The System Restore error usually happens because Microsoft Store apps are running and their folder can’t be replaced. Running System Restore from the Windows Recovery Environment (WinRE), where those apps aren’t running, often avoids it.

  1. Open Settings. In Windows 11 go to System > Recovery; in Windows 10 go to Update & Security > Recovery.
  2. Next to Advanced startup, select Restart now.
  3. Choose Troubleshoot > Advanced options > System Restore, sign in if asked, and pick the restore point.

If you can’t reach Settings, hold Shift while you select Restart from the power menu. If Windows says the recovery environment can’t be found, see Windows RE image was not found.

System Restore 0x80070091: rename the WindowsApps folder

If System Restore still fails, a widely used workaround is to rename the WindowsApps folder so the restore can create it again. Do this only if you need that restore point, and back up your personal files first.

  1. Restart into recovery as in the section above, but choose Troubleshoot > Advanced options > Command Prompt.
  2. Find the Windows drive. In recovery it’s sometimes not C:. Run dir C:\ and check that you see Program Files and Windows; if not, try D:.
  3. Run the commands below (use the right drive letter).
  4. Close Command Prompt, choose Continue to start Windows, and run System Restore again.
cd /d C:\Program Files
attrib -h WindowsApps
ren WindowsApps WindowsApps.old

After a successful restore, check that your Microsoft Store apps open. If some don’t, reinstall them from the Store. If System Restore still fails, rename WindowsApps.old back to WindowsApps the same way so the apps keep working.

If System Restore keeps failing with any restore point, repair Windows itself: run DISM /Online /Cleanup-Image /RestoreHealth and sfc /scannow (see Windows Resource Protection could not perform the requested operation if SFC fails), or do a repair install as described in how to reinstall Windows 10.

Official sources: for more detail, see Microsoft’s own documentation:

Frequently asked questions

Does error 0x80070091 mean my files are lost?

No. It only means Windows couldn’t remove or replace a folder. With System Restore, the message says your files and settings weren’t changed.

Why does the folder look empty but still give 0x80070091?

It usually contains hidden or system files, or the file system entry for the folder is damaged. Show hidden items, run dir /a on it, and run CHKDSK if that doesn’t explain it.

Is it safe to rename the WindowsApps folder?

It’s a common workaround, but it affects Microsoft Store apps, so treat it as a last resort, back up first, and rename the folder back if the restore still fails.

Can I just delete WindowsApps?

No. It holds your installed Store apps and parts of Windows features. Renaming it is reversible; deleting it isn’t.

How we write our guides: read our editorial policy.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *