Complete List of forbidden file and folder names for windows

后端 未结 3 702
囚心锁ツ
囚心锁ツ 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.

提交回复
热议问题