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.
|📥 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.
- Download and install Disk Drill. Avoid installing Disk Drill to the same drive that you’re recovering data from.
- Select the drive that’s causing the error message. Click Search for lost data. The scan will begin.
- 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.
- Select the files you want to recover. The Recovery chances column displays your chances of successfully recovering each file. When ready, click Recover.
- Choose an output location that resides on a separate physical partition to avoid corrupting your data. Click OK to finalize recovery.
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.
- Right-click the Start button, then select Windows PowerShell (Admin).
- Type chkdsk D: /f /r. (Replace D: with your own drive letter). Press Enter.
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.
- Navigate to the parent folder in Windows Explorer. Right-click the folder having issues, then select Properties.
- Go to the Security tab. Click Edit.
- 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).
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.
- Press CTRL + S on your keyboard and search for Windows Security. Open the first result.
- Click Virus & threat protection.
- Click Scan options.
- Select Full scan then click Scan now.
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.
- Press Windows Key + I to open Windows Settings. Click Update & Security.
- Click Recovery.
- Under Advanced startup, click Restart now. Your computer will restart.
- Click Troubleshoot.
- Select Advanced options.
- Click Startup Settings.
- Click Restart to boot into safe mode.
- Press 5 to boot into Windows safe mode with network access. If you don’t want network access, press 4 instead.
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.
- Open Windows File Explorer.
- Right-click the drive, then select Properties.
- Click Tools.
- Under Error checking, click Check.
- 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:
- Right-click Start. Select Windows PowerShell (Admin).
- 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.