Search code examples
windowswinapipathntfsunc

Are Extended-Length Paths safe to use?


I just stumbled on this article on MSDN that says a path can be 259 characters + NUL termination, but if you prefix it with "\\?\" WinAPI allows you to use the

maximum total path length of 32,767 characters.

Eager to see it working I tried using that prefix from Explorer (On XP SP3) but it doesn't work at all (on any path). If you put \\?\C:\Path\to\an\existing.file on explorer's bar, it will give the "file not found" error.

So I'm confused. Can I code something for (non-ancient) Windows that makes full use of the mentioned path size on NTFS? Why Explorer doesn't use it?


Solution

  • There is a SET of API calls that are work with extened-paths and some that do not. The MSDN usually mentions this.

    Not that if you just type that path into windows explorerunder xp this does not work, because the extened path syntax is just an escape sequence for the WIn32 API and not for windows explorer. Now, In Win7 this does work because many people expected this to work.

    Also for long paths, it does help if you change the working directory or open up explorer with a sub-directory as a root.