Does Microsoft Windows display a “The Directory Is Not Empty” error when you try to delete a folder? Your folder may be locked, or you may not have the required permission to remove the folder. You can follow a few easy methods to fix this problem and delete your folder successfully.

Some reasons you may not be able to remove your folder is that File Explorer is experiencing a minor glitch, your disk has a bad sector, you don’t have permission to remove the folder, or Windows’ system files are corrupt.

Table of Contents

    Restart File Explorer

    When you get a “The Directory Is Not Empty” error, an easy fix you can apply to fix your issue is to restart File Explorer. Doing so resolves any minor problems with your file manager utility, allowing you to delete your items without any problems.

    1. Right-click the Windows taskbar and choose Task Manager.
    2. Right-click Windows Explorer on the list and select Restart.
    1. Try to delete your folder.

    Renaming Your Folder to Resolve the Issue

    If you still can’t delete your folder, give your folder a new name, and then try to remove the item. This method should resolve the issue if a minor system glitch is causing the problem.

    1. Right-click the problematic folder and choose Rename. Alternatively, select the folder and press F2 on your keyboard.
    1. Enter a new name for your folder and press the Enter key.
    2. Right-click the folder and choose Delete.

    Delete the Folder Using the Free Unlocker App

    If you still can’t remove your folder, that may be because an app or service on your computer is using that folder. In this case, you can use a free app called Unlocker to remove all locking handles from your folder and delete the folder.

    1. Download and install the free Unlocker app on your PC.
    2. Launch the app and select Yes in the User Account Control prompt.
    3. Choose your problematic folder on the list and select OK.
    4. Unlocker will display the items locking your folder.
    5. Choose Delete from the drop-down menu and select OK.

    Delete Files Using Command Prompt

    Command Prompt is a good alternative to use when you can’t use File Explorer to remove items. You can use a command in this command-line utility to remove your chosen folder from your storage.

    1. Open the Start menu, find Command Prompt, and select Run as administrator.
    2. Choose Yes in the User Account Control prompt.
    3. Type the following command in CMD and press Enter. Here, replace PATH with the full path to the folder you want to delete.
      rmdir /s “PATH”

    Check Disk for Bad Sectors to Fix the Empty Error

    The hard disk where you’ve stored your folder may have a bad sector, preventing you from deleting your items. In this case, use Windows’ built-in CHKDSK command to find and fix bad sectors on your disk.

    1. Open Start, locate Command Prompt, and select Run as administrator.
    2. Choose Yes in the User Account Control prompt.
    3. Type the following command in CMD and press Enter. Here, replace C with the drive where you’ve stored the folder.

      CHKDSK /F C:
    1. Type Y on your keyboard and press Enter to unmount the drive.
    2. If you see a message asking you to schedule the fix on the next reboot, type Y and press Enter.
    3. Restart Windows, and CHKDSK will kick in to fix any bad items on your disk.

    Get Full Permission for Your Folder to Fix Error

    You may not have full permission for your folder, which leads to a “The Directory Is Not Empty” error when you try to remove the folder. You can fix that by taking ownership of your chosen folder.

    1. Right-click your folder and choose Properties.
    2. Select the Security tab and choose Advanced.
    3. Select Change next to Owner.
    4. Type your Windows username in the text box, select Check Names, and choose OK.
    1. Select Apply followed by OK.
    2. Choose OK on the Properties window.
    3. Try to remove your folder.

    Run a Full Virus Scan on Your Windows PC

    Your Windows PC may have a virus or malware infection, and this item may have gained unauthorized control over your folder, preventing you from deleting your folder. In this case, you can run a full virus check and find and remove all the threats from your PC.

    You can use a third-party antivirus program or Windows’ built-in Microsoft Defender Antivirus to scan your computer. Here are the steps for running a full scan using the latter.

    1. Open Start, find Windows Security, and launch the app.
    2. Select Virus & threat protection in the app.
    3. Choose Scan options on the following page.
    4. Select Full scan and choose Scan now.
    1. Wait for your antivirus to finish scanning your PC.

    Fix Corrupt Windows Files

    Windows’ operating system files may have become corrupt, causing your folder not to delete. In this case, you can use Windows’ built-in SFC (System File Checker) tool to find and fix all corrupt files on your computer.

    This tool runs from a Command Prompt window and recognizes and replaces all the faulty system files on your storage.

    1. Open Start, find Command Prompt, and select Run as administrator.
    2. Choose Yes in the User Account Control prompt.
    3. Enter the following on the Command Prompt window and press Enter:

      DISM.exe /Online /Cleanup-image /Restorehealth
    1. Then, use the following command to fix your corrupt files: sfc /scannow
    2. Try to remove the directory.

    Restore Your Windows System

    If Windows’ “The Directory Is Not Empty” error still doesn’t go away, roll back any recent changes you may have made to your PC. One way to do this is by using Windows’ built-in System Restore tool.

    This tool allows you to roll back your system to a restore point created in the past, which helps fix many issues.

    1. Open Start, find Recovery, and select the item in the search results.
    2. Choose Open System Restore on the following page.
    3. Select Next on the tool’s first screen.
    4. Choose the most recent restore point on the list and select Next.
    1. Select Finish to begin restoring your PC.

    Finally, You Can Delete Your Folder on Your Windows PC

    It quickly gets frustrating when you want to delete a folder but can’t do that as Windows keeps displaying the “The Directory Is Not Empty” error. Luckily, this error isn’t too hard to deal with, and you can use the methods above to resolve the problem.

    Once the item locking the folder is gone, you’ll be able to delete your folder without any issues.