Accessing files across the windows network with near MAX_PATH length

强颜欢笑 提交于 2019-12-23 20:15:06

问题


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.

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.

Can this file be accessed across the network even know the computer name in the UNC path puts it over the MAX_PATH limit?


回答1:


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

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.




回答2:


You might be able to get a handle to the file if you try opening the file after converting the file name to a short (8.3) file name. Failing that can you map the dir the file is in as a drive and access the file that way?



来源:https://stackoverflow.com/questions/112946/accessing-files-across-the-windows-network-with-near-max-path-length

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