在Windows网络上以接近MAX_PATH的长度访问文件 [英] Accessing files across the windows network with near MAX_PATH length
问题描述
我正在使用C ++并通过网络访问UNC路径.此路径略大于MAX_PATH.因此我无法获取文件句柄.
I'm using C++ and accessing a UNC path across the network. This path is slightly greater than MAX_PATH. So I cannot obtain a file handle.
但是,如果我在有问题的计算机上运行程序,则路径不大于MAX_PATH.这样我就可以获得文件句柄.如果我将文件重命名为更少的字符(减去计算机名称的长度),则可以访问该文件.
But if I run the program on the computer in question, the path is not greater than MAX_PATH. So I can get a file handle. If I rename the file to have less characters (minus length of computer name) I can access the file.
即使知道UNC路径中的计算机名已超过MAX_PATH限制,也可以通过网络访问此文件吗?
Can this file be accessed across the network even know the computer name in the UNC path puts it over the MAX_PATH limit?
推荐答案
我记得有一些功能,例如在路径的开头使用\\?\
来绕过MAX_PATH
限制.这是MSDN上的参考:
I recall that there is some feature like using \\?\
at the start of the path to get around the MAX_PATH
limit. Here is a reference on MSDN:
http://msdn.microsoft.com/en -us/library/aa365247(VS.85).aspx
对于远程计算机,您将使用路径名称,例如:\\?\unc\server\share\path\file
. \\?\unc\
是特殊前缀,不用作实际文件名的一部分.
For remote machines, you would use a path name such as: \\?\unc\server\share\path\file
. The \\?\unc\
is the special prefix and is not used as part of the actual filename.
这篇关于在Windows网络上以接近MAX_PATH的长度访问文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!