Reputation: 10077
So we all know that Windows programs by default are limited to dealing
with a maximum path length of 260 characters. However, this limit can easily be overcome by prefixing the path by the \\?\
character sequence.
For some reason, however, this isn't possible with relative paths, as MSDN says:
Because you cannot use the
\\?\
prefix with a relative path, relative paths are always limited to a total ofMAX_PATH
characters.
(source)
I don't really understand the reason why Microsoft decided to forbid relative paths to be prefixed with \\?\
so if there is some sort of rationale behind this decision, I'd be really glad to hear about it because it doesn't really make sense to me that \\?\
is only allowed for full paths.
My real question, though, is how to deal with this limitation: Should I simply call GetFullPathName()
on relative paths to extend them to full paths, then add the \\?\
prefix, and then pass that path to fopen()
etc., or what is the recommended way of dealing with this limitation?
Upvotes: 2
Views: 879
Reputation: 7170
You cannot use the \\?\
prefix with a relative path.
When relative path is passed to the system, it is parsed as absolute paths and then passed to the system. And as it is mentioned in the source:
The prefixes
\\:\
are not used as part of the path itself. They indicate that the path should be passed to the system with minimal modification, which means that you cannot use forward slashes to represent path separators, or a period to represent the current directory, or double dots to represent the parent directory.
Upvotes: 4