1. Home
  2. Microsoft
  3. Windows
  4. How to Fix Windows Error Code ERROR_145: A Step-by-Step Guide

How to Fix Windows Error Code ERROR_145: A Step-by-Step Guide


Encountering Windows Error Code ERROR_145—which means "The directory is not empty"—can be frustrating, especially when you’re trying to delete or move files and folders. But don’t worry! This common Windows error can be resolved with a few straightforward steps. In this detailed guide, we’ll walk you through each solution, explaining why the error occurs and how to fix it efficiently.


What is Windows Error Code ERROR_145?

ERROR_145 is a system error code that typically appears when an operation cannot be completed because the folder or directory you’re working with is not empty. This usually occurs when:

  • You try to delete a directory that still contains files or subfolders.
  • A program is locking the folder or files inside it.
  • File permissions or system errors are preventing folder modification.


Why Does ERROR_145 Occur?

The main reasons behind this error are:

  • Files or subfolders are still inside the folder. Even hidden files can prevent deletion.
  • Files are being used or locked by running applications.
  • File permission issues where your user account doesn’t have enough rights.
  • Corrupted files or disk errors.


Step-by-Step Guide to Fix Windows Error Code ERROR_145

Step 1: Ensure the Folder is Empty

Before attempting deletion or modification, make sure the folder is genuinely empty.

  • Open the folder.
  • Press Ctrl + A to select all files.
  • Press Delete, or right-click and choose Delete.
  • To see hidden files, click on the View tab in File Explorer and check Hidden items.
  • Delete any hidden files or folders present.

Step 2: Close Programs Using the Folder

Sometimes, files in the directory are in use by programs, which locks them:

  • Close any apps or documents related to the folder.
  • Open Task Manager (press Ctrl + Shift + Esc).
  • Look for any suspicious or related processes that might use the folder or its files.
  • Right-click those processes and select End Task.

Step 3: Use Command Prompt to Force Delete the Folder

Command Prompt can often bypass issues encountered in File Explorer:

  1. Press Windows + S, type cmd, right-click Command Prompt, and select Run as administrator.
  2. Use the following command to delete the folder (replace C:\Path\To\Folder with the actual path):

shell
rmdir /S /Q "C:\Path\To\Folder"

  • /S removes all directories and files in the specified directory.
  • /Q runs in quiet mode without asking for confirmation.

Step 4: Check and Repair Disk Errors

Disk errors can cause incomplete or "ghost" files preventing deletion:

  1. Open Command Prompt as administrator.
  2. Run the following command to check and fix disk errors:

shell
chkdsk C: /F /R

  • Replace C: with the drive letter containing your folder.
  • You may need to restart your PC for the scan to complete.

Step 5: Take Ownership and Reset Permissions

For permission-related issues, take ownership:

  1. Navigate to the folder in File Explorer.
  2. Right-click the folder, then select Properties.
  3. Go to the Security tab, then click Advanced.
  4. At the top, click Change next to “Owner”.
  5. Type your username, click Check Names and then OK.
  6. Check the box "Replace owner on subcontainers and objects".
  7. Apply changes. Then, in the Security tab, grant yourself Full Control permissions.
  8. Try deleting or modifying the folder again.

Step 6: Use Third-Party Unlocker Tools

If the error persists, tools like Unlocker or Process Explorer can help identify and release any file locks.

  • Download and install one of these tools.
  • Use it to locate and unlock any processes using files in the folder.
  • Try deleting the folder afterward.


Prevention Tips: Avoid ERROR_145 in the Future

  • Regularly clean temporary files and folders.
  • Close all files before deleting folders.
  • Maintain up-to-date disk health with regular scans.
  • Avoid abrupt shutdowns to minimize file system errors.


Final Thoughts

Windows Error Code ERROR_145 can interrupt your workflow, but with this step-by-step guide, you should be able to resolve the problem quickly and safely. If these methods don’t work, consider seeking additional help from a professional, as the issue might be more complex or hardware-related.

Remember, patience is key with system errors—don’t rush into deleting critical system files!


Did this guide help you fix ERROR_145?
Drop a comment below or share your experience. Your feedback helps us create better guides!


Keywords:

Windows Error Code ERROR_145, directory not empty error, fix ERROR_145, delete directory Windows, folder in use error, Windows folder permissions, chkdsk fix errors, Windows folder delete error


By implementing these steps, you’ll be back to managing your folders in Windows without errors, ensuring a smoother and stress-free computing experience!

Updated on June 20, 2025
Was this article helpful?

Related Articles

Leave a Comment