When you are trying to delete a file or folder on your system, you might come across the error message ‘Invalid file handle’. This error message occurs when the name of the folder or the file that you are trying to delete is a reserved name. The Windows operating system doesn’t deal with certain names/nicks due to which the File Explorer prevents you from giving your folder or file a reserved name. However, in case you get the file from your smartphone or another operating system like Linux, you will be prompted the said error message upon trying to delete it.
Microsoft Naming Conventions
The Microsoft Naming Conventions provide that files or folders on your system should not be named CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. This is because these names are reserved names in the Windows operating system, meaning they are used for a specific purpose by the Windows operating system and should not be used anywhere else. You should also avoid following the above names immediately by an extension, for example, NUL.txt. In case you want some more details, you can refer to this article on Microsoft’s website.
What causes the ‘Invalid File Handle’ Error Message on Windows 10?
Well, the reason for the emergence of the said error is quite clear after giving the Naming Conventions provided by Microsoft a read.
- The Name of the File/Folder is a Reserved Name: The error message occurs appears when the file you are trying to delete is given a reserved name. Using reserved names is prohibited by Microsoft and should not be trifled with.
Now that you are aware of the Microsoft Naming Conventions and the cause of the error message, you can overcome it by following the solution given down below.
Deleting the File or Folder
The files that are given a reserved name can be rendered useless because you can’t use them neither are you able to delete them using the standard procedure. To delete the file or folder, you will need to rely on some command prompt commands.
If you are facing the error message while deleting a directory, you can do so by following the steps given down below:
- Press Windows Key + X and select Command Prompt (Admin) from the list to open an elevated command prompt.
- Once the elevated command prompt opens up, type in the following command:
rd \\.\c:\documents\con /S /Q
- In the above command, replace the path accordingly, however, make sure you do not remove the ‘\\.’ before the path. Another example would be:
rd \\.\E:\con /S /Q
The parameter /S is used to tell the rd command to remove all the sub-directories found in the specified directory while the /Q parameter is used to tell the command to remove contents of the specified directory silently (you won’t be given any prompts). Moreover, \\. is used to refer to the current system.
In case you are trying to delete a file, do the following:
- Open an elevated command prompt as shown above.
- Type in the following command and then hit Enter:
- To delete a file, you will just have to specify the extension of the file and use the command del instead of rd.
That’s it, you have probably deleted the file/folder from your system.