views:

760

answers:

2

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?

A: 

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
+7  A: 

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
I use this for local paths, but not sure if/how it applies to remote computers.
Brian R. Bondy