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 :? ...)
Additionally, while spaces and dots can be included in file names, names including only those characters are forbidden.
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.
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.
The list of invalid characters is:
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.
A list of reserved device names:
http://www.blindedbytech.com/2006/11/16/forbidden-file-and-folder-names-on-windows/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With