127 - 问,MAX_PATH与CreateFile

127 - 问,MAX_PATH与CreateFile

MAX_PATH问题

今天测试提了个bug,后来找到原因是:测试创建了一个满字符长度的文件(重命名,输入的信息直到无法输入为止),导致我们的软件无法获取这个文件的扩展名等等信息。

查看CreateFile的文档,

Parameters

lpFileName [in]

The name of the file or device to be created or opened.

In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming Files, Paths, and Namespaces.

For information on special device names, see Defining an MS-DOS Device Name.

其实一直以来,ANSI version这句话没理解正确,现在想想,其实就是CreateFileA。

如果超长的文件,一定按照后面的说法。加上前缀\\?\。

你可能感兴趣的:(127 - 问,MAX_PATH与CreateFile)