How do I check if a given string is a legal/valid file name under Windows?

后端 未结 27 1356
-上瘾入骨i
-上瘾入骨i 2020-11-22 09:38

I want to include a batch file rename functionality in my application. A user can type a destination filename pattern and (after replacing some wildcards in the pattern) I n

27条回答
  •  抹茶落季
    2020-11-22 10:30

    From MSDN, here's a list of characters that aren't allowed:

    Use almost any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following:

    • The following reserved characters are not allowed: < > : " / \ | ? *
    • Characters whose integer representations are in the range from zero through 31 are not allowed.
    • Any other character that the target file system does not allow.

提交回复
热议问题