sodcalculator

10 Tech How-To

Directory Name Is Invalid Error in Windows 10: Fixes

Guide 10-57830 · Updated · Step by step

The “directory name is invalid” error in Windows 10 usually appears when you try to open, save, or delete a file or folder, and it means Windows cannot read the path to that location. The fix is typically to clear the File Explorer history, run a disk check, or repair the corrupted file path — here’s exactly how to do that step by step.

What Causes the “Directory Name Is Invalid” Error?

This error is almost always tied to a corrupted or inaccessible file path. Windows stores shortcuts, recent file lists, and thumbnail caches that point to specific folder locations. When one of those references becomes broken — for example, after moving an external drive, renaming a folder, or a failed update — Windows throws the “directory name is invalid” message.

Common triggers include:

  • Removing a USB drive or SD card without safely ejecting it, leaving behind a dead shortcut.
  • Deleting or renaming a folder that is still referenced in File Explorer’s “Recent files” or “Quick access” lists.
  • Corrupted thumbnail cache or icon cache files.
  • A failing hard drive with bad sectors that make a directory unreadable.
  • Malware or a third-party cleanup tool that removed registry entries incorrectly.

In most cases the actual files are still fine — the problem is just that Windows lost its way to them. That’s why the fixes below focus on clearing stale references and repairing the underlying drive.

Fix 1: Clear File Explorer History and Quick Access

File Explorer keeps a history of folders you’ve opened, and if one of those no longer exists, it can trigger the error when you try to browse or use “Recent files.” Clearing this history is quick and safe:

  1. Open File Explorer (Win + E).
  2. Click the View tab on the ribbon.
  3. Click Options (on the far right), then the General tab.
  4. Under Privacy, click Clear next to “Clear File Explorer history.”
  5. Also click Clear next to “Clear Quick access recent files.”
  6. Click OK and restart File Explorer.

If the error was caused by a stale shortcut in Quick access, this will usually fix it. You can also right-click any pinned item in Quick access and choose “Unpin from Quick access” to remove a specific broken link.

Fix 2: Run a Disk Check (CHKDSK)

If the error appears when accessing a specific drive or folder, the drive itself may have file system corruption. Windows includes a built-in tool to scan and repair this:

  1. Open Command Prompt as administrator (right-click Start and choose “Command Prompt (Admin)” or “Windows PowerShell (Admin)”).
  2. Type chkdsk C: /f /r (replace C: with the drive letter that’s failing).
  3. If the drive is in use, you’ll be asked to schedule the scan for the next restart — type Y and press Enter.
  4. Restart your PC and let the scan run. It may take a while on large drives.

The /f flag fixes errors, and /r locates bad sectors and recovers readable information. If you’re not comfortable with the command line, you can also right-click the drive in File Explorer → Properties → Tools → Check. This does the same thing but with a GUI.

Note: CHKDSK cannot fix physical damage to a hard drive. If it reports bad sectors repeatedly, back up your data immediately and consider replacing the drive.

Fix 3: Clear the Thumbnail and Icon Cache

A corrupted thumbnail cache can cause the error when you open a folder that displays image or video previews. Clearing it is harmless — Windows rebuilds it automatically:

  1. Open File Explorer and go to the View tab.
  2. Check the box for Hidden items (so you can see the cache folders).
  3. Navigate to C:\Users\\AppData\Local\Microsoft\Windows\Explorer.
  4. Select all files that start with thumbcache_ and delete them.
  5. Restart your PC. Windows will recreate the thumbnails as you browse.

If you prefer a command-line approach, open Command Prompt as admin and run:

ie4uinit.exe -show

This refreshes the icon cache without deleting anything. Some users also use the Disk Cleanup tool (cleanmgr) → select “Thumbnails” → OK, which is a safer GUI alternative.

Fix 4: Check for a Corrupted Shortcut or File Path

If the error appears when launching a specific program or opening a specific file, the shortcut may point to a location that no longer exists. Right-click the shortcut and choose Properties → Shortcut tab. Look at the “Target” field — if the path includes a drive letter that’s not currently connected (like E:\ for an external drive), that’s the problem. Update the target to the correct location, or delete the shortcut and create a new one.

For files, try moving the file to a new folder with a simple name (like C:\Temp) and opening it from there. This can bypass a path that’s too long (over 260 characters) or contains invalid characters. Windows 10 supports long paths if you enable them via Group Policy (Computer Configuration → Administrative Templates → System → Filesystem → “Enable Win32 long paths”), but that’s only for applications that respect it.

Fix 5: Use System File Checker (SFC) and DISM

If the error persists, Windows system files may be corrupted. Run these two built-in tools in order:

  1. Open Command Prompt as administrator.
  2. Type sfc /scannow and press Enter. This checks protected system files and repairs them.
  3. After it finishes, run DISM /Online /Cleanup-Image /RestoreHealth. This repairs the Windows image itself.
  4. Restart your PC.

SFC can take 10–20 minutes. If it finds issues it will fix them automatically. DISM may take longer, but it’s a reliable way to fix deeper corruption that SFC can’t handle.

Fix 6: Check for Malware and Third-Party Conflicts

Rarely, the error is caused by a program that interferes with file access — like an antivirus that quarantines a folder, or a “cleaner” tool that removed registry entries. Run a full scan with Windows Defender (or your preferred antivirus). Also try booting into Safe Mode (Settings → Update & Security → Recovery → Advanced startup → Restart now → Troubleshoot → Advanced options → Startup Settings → Restart → press 4). If the error doesn’t appear in Safe Mode, a third-party program is likely the culprit. Uninstall recently installed software that might affect file paths, especially cloud sync tools or virtual drive software.

Frequently Asked Questions

Will I lose my files if I run CHKDSK?

No, CHKDSK is designed to repair the file system without deleting your data. However, if it finds corrupted files that cannot be recovered, it may move them to a folder like found.000 on the drive. Always back up important data before running a disk check, just in case.

Why does the error happen only with external drives?

External drives are often removed without safely ejecting, which can leave the file system in an inconsistent state. The drive letter may also change when you reconnect it, so shortcuts that point to the old letter become invalid. Reconnect the drive, assign it the same letter via Disk Management, or use the fixes above to clear stale references.

Can I fix this error without admin rights?

Clearing File Explorer history and deleting thumbnail caches do not require admin rights. However, running CHKDSK, SFC, and DISM require administrator privileges. If you’re on a work or school computer, contact your IT department for help.

Is this error a sign that my hard drive is failing?

Not necessarily. It’s often just a broken shortcut or cache issue. But if you also notice strange noises, slow performance, or frequent crashes, run a drive health check (like wmic diskdrive get status in Command Prompt) and back up your data as a precaution.

What if none of these fixes work?

If the error persists after all the steps, try creating a new user account and see if the error occurs there. If it doesn’t, your user profile is corrupted. If it does, the problem is system-wide — consider using System Restore to a point before the error started, or perform a Windows 10 repair install using the Media Creation Tool (which keeps your files and apps).

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →