UGTS Document #30 - Last Modified: 8/29/2015 3:23 PM
Windows Reserved Filenames

Windows has many filenames and sharenames which are reserved and cannot be used due to backwards compatibility restraints:
  • AUX / COM / CON / LPT / NUL / PRN - Due to backwards compatibility requirements with scripts and batch files which were written to work with DOS 1.0 any file name that imitates a DOS 1.0 device cannot be used as a normal filename, and the full list is described here: NUL, PRN, AUX, CON, COM[1-9], LPT[1-9]. Nor should you use an filename which has a basename of one of these and a file name extension, such as CON.txt.

  • Any filename that ends with a dot - While the filesystem supports such a filename, the shell and windows Explorer don't, and if you try to name a file in this way through Explorer, the final dot will be removed. And if you try to name a file simply '.' by itself, Explorer will tell you that you must type a filename. Note that this prevents you from naming a file '.' or '..' which would be confused with the current directory and previous directories for paths. However, note that it is possible to name a file that starts with a dot., and this is often done when you have to create filenames such as ".htaccess".

  • Any filename that that has unsafe characters - All characters with ASCII values less than 32 should be considered unsafe, as well as < (less than), > (greater than), : (colon), " (double quote), / (forward slash), \ (backward slash), | (vertical bar), ? (question mark), * (asterisk). These special characters are reserved for use as delimiters in paths and batch file commands. These specific characters also return by the .NET function IO.Path.GetInvalidPathCharacters.

  • Any filename with special unicode 'look-alike' characters - The character 0xA0 is the Unicode non-breaking space character. It looks just like a space character but it isn't, and doesn't compare equally to the garden variety space character 0x20. Although you can use such characters in filenames, you shouldn't without good reason, because it can be very confusing if you try to type the filename from the command line and wonder why no file with that name is found, or wonder why a directory is allowing multiple files that appear to have exactly the same filename, or when you have multiple such files with seemingly identical names, and you're trying to tell them apart to open or delete the right one. Such files often have to be accessed using the command line or programmatically using scripts.

  • Directory names ending in .com - When creating home directories for websites, it can be tempting to name a directory with a name that ends in .com, after the domain name of the site. But you shouldn't do this, because some software (such as FrontPage) misinterprets such a filename as being a '.com' executable file (even though it is a directory), and will not open it.

  • Reserved file share names - The names 'pipe' and 'mailslot' cannot be used as a file share name because they are reserved for use in accessing named pipes in mailslots in the Windows API. You can create and share a folder with this name, but if you try to access it with a UNC path, you will get a File Not Found error because Windows will be trying to open a named pipe or mailslot instead of the folder you've shared. Also, any drive letter share such as C$, D$, etc... cannot be used because these are the administrative share names for the drives on the system. Likewise, Admin$ and IPC$ are also reserved by Windows and can't be used.

  • Filenames with leading or trailing spaces - Although the filesystem supports such names, the shell and many other programs don't (such as FTP clients), and it can be very hard to access or delete such files if they are present without using the command line or scripts, or to know why the filesystem is seemingly allowing multiple files to have the same name. This is similar to the recommendation not to use Unicode look-alike characters.