我的工具需要读取公司服务器上存放的文件,但近来发现有些文件因路径过长导致我的工具访问失败,用fopen和CFile::Open都失败,GetLastError的值都是3(系统找不到指定的路径),请问有什么办法解决?谢谢!
PS. 打开记事本,将服务器文件拖入,是可以读取的,它是如何做到的?
谢谢!(很久没来坛里了,全部分给出,很可怜,望海涵)
...全文
52312打赏收藏
【急!】fopen和CFile::Open所能打开的文件的绝对路径最长是多少?
我的工具需要读取公司服务器上存放的文件,但近来发现有些文件因路径过长导致我的工具访问失败,用fopen和CFile::Open都失败,GetLastError的值都是3(系统找不到指定的路径),请问有什么办法解决?谢谢! PS. 打开记事本,将服务器文件拖入,是可以读取的,它是如何做到的? 谢谢!(很久没来坛里了,全部分给出,很可怜,望海涵)
在WINDOWS上,这些函数最张都会调用API CreateFile
https://msdn.microsoft.com/en-us/library/aa363858.aspx
注意以下内容
Parameters
lpFileName [in]
The name of the file or device to be created or opened. You may use either forward slashes (/) or backslashes (\) in this name.
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.
对 CreateFile MSDN 上有这样的说明
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.