“The Directory Name is Invalid” Error and How To Fix It

Approved by

the directory name is invalid

After booting up your computer and attempting to open one of your folders, you’re met with a Windows prompt that says “the directory name is invalid”. Any further attempts at accessing your folder are met with the same repeated error message.

This error can occur for many reasons. Sometimes it’s as simple as incorrect permissions, other times it could be a result of bad sectors on your drive. Either way, this article will provide an understanding of what causes this problem and how you can fix it.

Common Causes of “The Directory Name Is Invalid” Error

This error occurs when, for some reason, Windows unsuccessfully attempts to access a directory. It could be triggered by you manually, or by Windows trying to run a program in the background. It can also happen when your USB flash drive isn’t recognized and Windows tries to access it. Listed below are some common reasons why this can happen to you.

Cause Description
📥 Improper device removal Removing your device without safely ejecting it first can interrupt delicate write processes, resulting in incomplete transfers that can corrupt your data or file system.
🗯 Malware attack A virus could have infected your drive, potentially corrupting your file system and preventing Windows from accessing certain parts of your drive.
📂 Incorrect permissions If you do not have the correct permissions to access the folder or device, Windows may return this error message as an indicator.
💿 Bad sectors on the drive Windows is unable to detect bad sectors by default, so it’s possible that it’s trying to access a location that is no longer accessible.

If Windows is saying the directory name is invalid, you should first look at recovering your data before applying any fixes to ensure none of your files are lost in the process.

How to Recover Files When the Directory Name Is Invalid

If your drive says the directory name is invalid on your Windows 10 computer, recovering the data is still possible as long as the drive is recognized by the Device Manager. Although you may not be able to retrieve your data using Windows Explorer, you can use specialized data recovery software to find and recover the data for you.

Disk Drill is a data recovery tool that we use often because of its reliability and speed. Follow these steps to recover any files on a drive that’s saying the directory name is invalid.

  1. Download and install Disk Drill. Avoid installing Disk Drill to the same drive that you’re recovering data from.
  2. Select the drive that’s causing the error message. Click Search for lost data. The scan will begin.Scanning the drive using Disk Drill.
  3. Click Review found items to look at what Disk Drill has found. You can do this during the scan or after it has been completed.Looking at what Disk Drill found.
  4. Select the files you want to recover. The Recovery chances column displays your chances of successfully recovering each file. When ready, click Recover.Recovering the marked files.
  5. Choose an output location that resides on a separate physical partition to avoid corrupting your data. Click OK to finalize recovery.Finalizing recovery in Disk Drill.

How to Fix “The Directory Name Is Invalid” Issue

Once you’re finished with file recovery, you can safely move on to diagnosing and fixing your drive so the error message no longer appears. Work through each method to ensure you don’t miss any important troubleshooting steps.

Method 1: Try Another Port

If Windows says the directory name is invalid when your USB, SD card, or external hard drive is connected, it may be caused by the USB port you’re connecting to. If the USB port is faulty, it can act erratically when devices are connected and break down communication between the device and your operating system.

Try connecting to another USB port. If successful, you can diagnose the original USB port to resolve the issue.

Method 2: Fix Using CheckDisk

CheckDisk is a utility included with Windows that specializes in finding and resolving issues relating to your drive’s file system. If, say, your drive has some bad sectors, CheckDisk will be able to identify them and mark them so Windows knows not to save new data to that space.

Running CheckDisk may fix the issue that’s triggering Windows to say that the directory name is invalid when opening a file. Follow these steps to do so.

  1. Right-click the Start button, then select Windows PowerShell (Admin).Opening an elevated PowerShell window.
  2. Type chkdsk D: /f /r. (Replace D: with your own drive letter). Press Enter.Running the CheckDisk command.

Method 3: Check Permissions

If your drive is NTFS-formatted and you do not have the correct permissions to view the file or folder, Windows may reject your attempt by saying the directory name isn’t valid. Permissions are used to secure your data and protect them from other users accessing it, especially on shared computers.

You may need to be logged in to (or know the credentials to) an administrator account to perform this if your own account lacks access.

Follow these steps to check the permissions of a folder and update them if necessary.

  1. Navigate to the parent folder in Windows Explorer. Right-click the folder having issues, then select Properties.Accessing the folder properties.
  2. Go to the Security tab. Click Edit.Editing the user permissions.
  3. Select your user account and make sure you have the correct access. In particular, you want to have read and write access. If the Allow box for either of these is unticked, tick them and click Apply (also make sure that the Deny box is unticked, as it will always take priority).Reviewing the user permissions.

Method 4: Check for Viruses

Viruses can do a multitude of malicious things to your drive. This includes the ability to delete directories or tamper with them in a way that prevents Windows from reading them. Thankfully, recovering deleted files is possible. But, if your computer has been infected by a virus, you may need to remove it first to resolve the Windows message that states the directory name is not valid.

You can scan your computer with any antivirus software, but these steps will guide you through performing a scan using Windows Security.

  1. Press CTRL + S on your keyboard and search for Windows Security. Open the first result.Open Windows Security.
  2. Click Virus & threat protection.Selecting the Virus & Threat protection section.
  3. Click Scan options.Checking the additional scan options.
  4. Select Full scan then click Scan now.Running a full scan using Windows Security.

Method 5: Boot Into Safe Mode

When you boot into safe mode, Windows only loads the files that are necessary for your computer to function. Anything extra will not be loaded on boot to prevent it from interfering with Windows. This gives you the opportunity to diagnose the problem, like uninstalling suspicious software and running repair utilities.

  1. Press Windows Key + I to open Windows Settings. Click Update & Security.Opening Windows settings.
  2. Click Recovery.Accessing the Windows recovery section.
  3. Under Advanced startup, click Restart now. Your computer will restart.Booting into advanced startup.
  4. Click Troubleshoot.Accessing the troubleshooting options.
  5. Select Advanced options.Checking the advanced options.
  6. Click Startup Settings.Clicking Startup Settings.
  7. Click Restart to boot into safe mode.Restarting the computer.
  8. Press 5 to boot into Windows safe mode with network access. If you don’t want network access, press 4 instead.Choosing how to boot safely.

Once you’re in safe mode, see if the message still appears. If it doesn’t, this means it could be in relation to an application on your computer. Now that you’re aware, you can restart your computer like normal and look through your installed applications to see if there are any that could be causing this.


If you connect your external hard drive and it says the directory name is invalid, the first thing you should do is try connecting it to another USB port (preferably a back panel one on desktops as it connects directly to the motherboard). 

If that doesn’t work, you can see if it’s an issue with the file system by checking the drive for errors using the building error checking function (that utilizes CheckDisk) in Windows.

  1. Open Windows File Explorer.
  2. Right-click the drive, then select Properties.
  3. Click Tools.
  4. Under Error checking, click Check.
  5. Click Scan drive.

This means the file has either been renamed, moved, or deleted. Microsoft Word will display this message when it is unable to locate the file you’re trying to open. Try using Windows Explorer to search for the file manually, either by keyword or file extension.

If your external hard drive, SD card, or USB directory name is invalid, it could be a problem with the file system. Use CheckDisk to scan for and fix any file system related issues with the external hard drive by following these steps:

  1. Right-click Start. Select Windows PowerShell (Admin).
  2. Type chkdsk D: /f /r. (Replace D: with your own drive letter). Press Enter.

If you’re trying to run something in a task scheduler but it returns the error code 0x8007010B, it’s very likely being caused by the use of quotation marks for the specified location. Removing the quotation marks surrounding the directory path should resolve the issue.

This field is required
This field is required
We respect your privacy; your email address will not be published.

We respect your privacy; your email address will not be published.

You have entered an incorrect email address!
This field is required