Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Complete List of forbidden file and folder names for windows

Tags:

windows

On Windows file names like com1.txt or lpt1.txt are forbidden. Is there a list of all forbidden file and folder names on windows (or forbidden chars in the file and folder names like :? ...)

like image 977
sdu Avatar asked Nov 16 '10 14:11

sdu


People also ask

Which of the following is not allowed in a file name in Windows 10?

Additionally, while spaces and dots can be included in file names, names including only those characters are forbidden.

What name Cannot be used for a folder?

You can't create folders in Windows OS having CON, PRN, NUL, etc. as the name. This is because these folder names are reserved for use in specific system tasks. You can use the command prompt, or blank space code to create folders with reserved names in Windows.

How do I get a list of filenames in a folder?

Type "dir /b > dirlist. txt" without quotes and press "Enter." This creates a list containing file names only. To include file sizes and dates, type "dir > dirlist. txt" instead.


2 Answers

The list of invalid characters is:

  • < (less than)
  • > (greater than)
  • : (colon)
  • " (double quote)
  • / (forward slash)
  • \ (backslash)
  • | (vertical bar or pipe)
  • ? (question mark)
  • * (asterisk)

Plus characters 1 to 31

Source

But you should use System.IO.Path.GetInvalidFileNameChars and System.IO.Path.GetInvalidPathChars (or their equivalents) as recommended by FlipScript as a) it's neater and b) means that if the list ever changes you won't have to modify your application.

like image 140
ChrisF Avatar answered Oct 05 '22 23:10

ChrisF


A list of reserved device names:

http://www.blindedbytech.com/2006/11/16/forbidden-file-and-folder-names-on-windows/

like image 43
Pacane Avatar answered Oct 06 '22 01:10

Pacane