windows - Windows 文件名中的分号?

标签 windows getopenfilename

我的一位用户问为什么我的应用程序不支持文件名中的分号。我单步执行了我的代码,似乎 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/

相关文章:

python - 为什么我的 Python 脚本在终端中暂停?

python - Pyautogui 屏幕截图。它去哪儿了?如何保存以后查找?

windows - 将 Unix ImageMagick 脚本转换为 Windows 批处理文件

c++ - 无法关闭 OPENFILENAME

excel - 如何只获取文件名而不是打开文件的整个文件路径?

windows - 如何从 Windows 10 专业版安装文件中获取 install.wim

C++ win32 应用程序在我从文件对话框中选择文件一段时间后卡住?

excel - Excel 2016 上的 getopenfilename VBA 代码

excel - Vlookup 语法和用户输入问题

c - 多线程 Windows 回调函数