System.IO.Path.GetInvalidPathChars()提供无效字符列表。
但我需要所有有效字符的列表。
首先想到的一个简单的想法是从0到255进行迭代并排除无效的字符,但它是否只给出有效字符?还有Unicode呢?我应该从0迭代到65535吗?

最佳答案

恐怕.net中没有任何东西可以获取这些信息。
您可以查看以下Microsoft页面:http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx
相关摘录:

Use 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:

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

    Integer value zero, sometimes referred to as the ASCII NUL character.

    Characters whose integer representations are in the range from 1 through 31,
    except for alternate data streams where these characters are allowed.

    Any other character that the target file system does not allow.

09-10 04:16
查看更多