Complete List of forbidden file and folder names for windows

后端 未结 3 689
囚心锁ツ
囚心锁ツ 2021-01-05 08:49

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 n

相关标签:
3条回答
  • 2021-01-05 09:15

    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.

    0 讨论(0)
  • 2021-01-05 09:25

    A list of reserved device names:

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

    0 讨论(0)
  • 2021-01-05 09:27

    You didn't mention what platform you are using, but in .Net, you can use:

    System.IO.Path.GetInvalidFileNameChars
    

    and

    System.IO.Path.GetInvalidPathChars
    

    To return invalid file name and path characters.

    0 讨论(0)
提交回复
热议问题