3

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?

Aardvark
  • 8,474
  • 7
  • 46
  • 64
Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636

2 Answers2

10

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.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
0

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?

Daniel
  • 4,847
  • 1
  • 23
  • 19