我的一位用户问为什么我的应用程序不支持文件名中的分号。我单步执行了我的代码,似乎 Windows 函数 GetOpenFileName 会截断任何包含分号的文件名。例如“一;二.wav”->“一”。
Microsoft 说不允许使用冒号,但不要提到分号...
http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx
它们是否合法?
编辑:..以及如何让 GetOpenFileName() 在文件名中使用分号?
哦!,奇怪 - 文件名是正确的,除了“滚动”到左边。所以“one;two.wav”看起来像“two.wav”,直到我单击它并按向左箭头(然后就可以了)。所以这不是错误,只是奇怪的行为。
最佳答案
Semicolons are legal in NTFS file paths .
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 streams where these characters are allowed.
- Any other character that the target file system does not allow.
我可以在我的 Win7 系统上为文件名添加分号。注意代码,可能是您的代码或第三方代码,这些代码使用意想不到的字符(最明显的是空格)执行奇怪的操作。
关于windows - Windows 文件名中的分号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3869594/