Search code examples
c++windowsvisual-c++lanunc

Accessing files across the windows network with near MAX_PATH length


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?


Solution

  • 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.