Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, October 23, 2017 2:00 PM
Not sure if this is the right place to ask this...
If I have an application that needs to deal with long paths, my understanding is that I can prefix the path (if it isn't already) with "\?\ to enable long path support. This works fine for local paths, resulting in things like "\?\C:\Folder\long path name\...
For UNCs, it looks like the documented thing to do (as per this doc) is to use "\?\UNC\Server\Share", but I can't get this to work, including just trying it with DIR in a command prompt.
So, in a command prompt, all the following give the expected directory listing:
dir "C:\Foldername"dir "\\?\C:\Foldername"dir "\\Servername\Sharename"
But this:
dir "\\?\UNC\Servername\Sharename"
gives "The filename, directory name or volume label syntax is incorrect".
I get the same error with no appreciable delay if I specify a non-existent server, implying that it's failing at parsing the path, and not getting as far as trying to resolve or contact the server.
Can someone clarify what syntax is required for a UNC with long path support? I've tried this with a variety of servers, and the same results for each. I've also tried various clients, with the same results for each (Win10 Creators, Win7 SP1).
If I have the UNC mapped as a drive letter, and use the "\?\X:\ method, it works fine (tested with paths over 300 chars long), so there isn't an issue with long path support itself at the server end.
All replies (4)
Tuesday, October 24, 2017 4:37 AM âś…Answered
Hi Mike,
According to the error prompt, it could i be that you are using certain characters in your path that are not supported. Please do a check
https://technet.microsoft.com/en-us/library/cc956689.aspx
In addition, please also refer to the thread discussed before.
Best Regards,
Mary
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].
Tuesday, October 24, 2017 9:47 AM
Not sure what you mean by certain characters not being supported. The only unusual character there is the ? in the "\?\ prefix, and that doesn't cause any problems when used with drive letters. Everything else is straight alphabetic characters, space and the folder separator (\.
The other thread is interesting, as it's clearly describing the same issue and implies that this is a limitation of the DIR command. Which is odd, but fair enough if that's a known issue.
Having done some more testing, I can confirm that while
dir \\?\UNC\server\share
does not work, other commands do, so e.g. this works:
copy \\?\UNC\server\share\filename.txt .
As does:
notepad \\?\UNC\server\share\filename.txt
However, things are still more complicated than that. Notepad works with such paths, but only so long as they stay within 260 characters. i.e. the prefix that's supposed to ensure long path support does not work in that case. This seems to be a notepad limitation. If you try it with a longer path you get an error that it can't find the file and the error message shows the path truncated to 259 chars.
However, for my purposes I'm only concerned with copy and delete for files, and create and delete for folders, and that looks like it works OK. It would be useful, to say the least, if the documentation mentioned that \?\UNC type paths don't work with dir.
Wednesday, October 25, 2017 2:13 AM
Hi Mike,
For now, I couldn't find the official documents mentioned that \?\UNC type paths don't work with dir.
Have also seen the scenario before. But for now, not mention the root cause for this.
It is also appreciated that the other members in our forum can share their experience with us about this scenario.
Best Regards,
Mary
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].
Wednesday, October 25, 2017 8:51 AM
Just to confirm - in the application the \?\UNC\ paths work fine for what I'm doing. I've marked the post above that links to the other thread as the answer in this case.