How to fix Error 145 on Windows 11

Windows 11 Error 145: “The Directory Is Not Empty” — Troubleshooting Guide

Why This Error Happens

Error 145 typically occurs when Windows attempts to delete, rename, or move a folder using RMDIR (or an underlying API call) while it still contains files, subfolders, or hidden system items that aren’t immediately visible in File Explorer. This often happens due to file system corruption, orphaned index entries, or another process (like antivirus software or a background service) holding a lock on a file inside that directory, preventing Windows from confirming it’s truly empty. In some cases, NTFS metadata corruption on the drive causes the system to falsely report contents even when the folder appears empty.

Step-by-Step Resolution Guide

  1. Check for Hidden/System Files
    Open File Explorer, go to View > Show > Hidden items. Navigate to the problematic folder and manually delete any hidden .tmp, .ini, or Thumbs.db files that may be lingering.

  2. Close Background Processes Locking the Folder
    Open Task Manager (Ctrl+Shift+Esc), and end tasks related to antivirus scanners, sync clients (OneDrive, Dropbox), or File Explorer itself. Restart explorer.exe via Task Manager (File > Run new task > explorer.exe).

  3. Run CHKDSK to Fix File System Errors
    Open Command Prompt as Administrator and run:

   chkdsk C: /f /r

Replace C: with the appropriate drive letter. Restart your PC if prompted, as CHKDSK will run on the next boot to repair NTFS inconsistencies.

  1. Force Delete via Command Prompt
    Open Command Prompt as Administrator and run:
   rmdir /s /q "C:\Path\To\Folder"

This forces a recursive deletion, bypassing some File Explorer glitches that trigger Error 145.

  1. Take Ownership and Reset Permissions
    Right-click the folder > Properties > Security > Advanced. Change the owner to your user account, enable “Replace owner on subcontainers and objects,” then apply full control permissions before retrying the deletion.

Alternative or Verification Steps

  • Verify the Fix: After deletion, refresh File Explorer (F5) and confirm the folder no longer appears; also re-run chkdsk C: /f to ensure no residual disk errors remain.
  • Alternative Tool: If the issue persists, boot into Safe Mode and attempt the deletion again, or use a third-party tool like IObit Unlocker to force-remove locked files/folders.