When I was trying to delete a folder from my local harddrive (cygwin64 in my case) I got the following error message: “Invalid file handle.“:

Invalid file handle

I then attempted to delete the folder from the command prompt which failed as well with an “Access is denied” error:

image

When I tried to open the CON.cif file with notepad it showed “Cannot find the file” error:

Cannot find the file \\.\CON.txt file | Do you want to create a new file?

The MSDN article “Naming Files, Paths, and Namespaces” explains why:

  • Do not use the following reserved names for the name of a file:
    CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended
  • The solution is to prefix the file name with either \\.\ or \\?\ and delete the file from the command prompt.