How to create a filename with a trailing period in Windows?

▼魔方 西西 提交于 2019-11-30 09:21:10

I figured out how to do this. Apparently, passing a normal filename will strip the period even when calling the Win API directly from C. In order to create the weird filenames, you must use the \\?\ prefix (this also disables relative paths and slash conversion).

open('\\\\?\\C:\\whatever\\test.','w')

It's ugly and nonportable, but it works.

The \\?\ syntax also works with cmd.exe:

dir>"\\?\C:\whatever\test."

Windows will strip the final trailing period, assuming it is the delimiter between a filename and a blank extension. Try using two periods.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!