根据http://msdn.microsoft.com/en-us/library/system.io.path.getinvalidpathchars%28v=vs.110%29.aspx Path.GetInvalidFileNameChars()应该给出以下输出
// Note: Some characters may not be displayable on the console.
// The output will look something like:
//
// The following characters are invalid in a path:
// Char Hex Value
// ", 0022
// <, 003C
// >, 003E
// |, 007C
// ...
//
// The following characters are invalid in a filename:
// Char Hex Value
// ", 0022
// <, 003C
// >, 003E
// |, 007C
// ...
Run Code Online (Sandbox Code Playgroud)
然而我只是得到
Char Hex Value
, 0000
/, 002F
Run Code Online (Sandbox Code Playgroud)
这是怎么回事?
从您链接的文章中:
不保证从此方法返回的数组包含文件名和目录名中无效的完整字符集。完整的无效字符集可能因文件系统而异。例如,在基于 Windows 的桌面平台上,无效路径字符可能包括 ASCII/Unicode 字符 1 到 31,以及引号 (")、小于 (<)、大于 (>)、竖线 (|)、退格 ( \b)、空 (\0) 和制表符 (\t)。