One of our customers habitually use very long path names (several nested folders, with long names) and we routinely encounter "user education issues" in order to shorten the path to less than 260 characters.

Is there a technical solution available, can we flick some sort of switch in Windows 7 and Windows 2008 R2 to say "yeah just ignore these historical problems, and make +260 character path name work".

P.S. I have read and been totally unedified by Naming Files, Paths, and Namespaces

  • 3
    Here we are in 2018 and the problem still exists in ROBOCOPY. 255 limit. Those exceeding it simply beep but don't copy. – SDsolar May 23 at 23:36
up vote 12 down vote accepted

The methods are there, but until Microsoft re-codes the file-browser widget we're pretty much stuck with that old problem. It's sub-optimal, but that's just how it works.

  • 4
    Bug in MS software that has been unfixed for few OS releases, that's a new one... – Hubert Kario Nov 24 '11 at 0:01
  • Windows 10 1607 finally fixed the file-browser problem and has some wizardry to fool Win32 applications in to working in this strange new world of huge paths: howtogeek.com/266621/… – HackSlash Jul 31 at 22:44

Just mentioning a trick I do not see mentioned here yet.

Take this file for example:

C:\Folder1\Really Long Path\Such Recursion\So Deep\Wow\Still Going\I will run out of ideas soon\I have organizational problems\Obsessive compulsive subdirectory disorder\Here is a guid for no good reason\936DA01F-9ABD-4d9d-80C7-02AF85C822A8\Almost there\Tax Returns\2013\2013_tax_return.pdf

This full file path is 290 characters long. The shell (Windows Explorer) and most command line utilities probably won't let you touch it.

Use the subst command like so:

subst X: "C:\Folder1\Really Long Path\Such Recursion\So Deep\Wow"

Now you can access (and delete, move, etc.) the file thusly:

X:\Still Going\I will run out of ideas soon\I have organizational problems\Obsessive compulsive subdirectory disorder\Here is a guid for no good reason\936DA01F-9ABD-4d9d-80C7-02AF85C822A8\Almost there\Tax Returns\2013\2013_tax_return.pdf

And now that file name is only ~235 characters or so, so you will not encounter the "Filename is too long" problems any more.

In the Windows API, there is an infamous constant known as MAX_PATH. MAX_PATH is 260 characters. The NTFS file system actually supports file paths of up to 32,767 characters. And you can still use 32,767 character long path names by accessing the Unicode (or "wide") versions of the Windows API functions, and also by prefixing the path with \\?\.

MAX_PATH was set in stone a very long time ago in the Windows world. I think it has something to do with ANSI standards at the time... but it's one of those things that's very difficult for Microsoft to change now, as now we have thousands of programs and applications, including some written by Microsoft themselves, that use MAX_PATH and would fail in strange new ways if the constant were suddenly changed. (Buffer overflows, heap corruption, etc.)

  • 4
    I've been taking an approach similar to subst by using directory junctions, which may be more convenient to cleanup if you're just looking to make a few quick changes. I use Link Shell Extension, but you can just use the mklink command like so: mklink /J C:\Wow "C:\Folder1\Really Long Path\Such Recursion\So Deep\Wow". – Charles Grunwald Sep 27 '15 at 3:10

You can get around this limitation by using the \\?\C: notation. It's ugly, but it supports file lengths up to 2^15.

http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath

  • 1
    Yeah I read that, as I said (see my link). But how do I benefit from it exactly? Can I map a drive to \\?\something for example. I don't understand. The article is intended for programmers using windows APIs. Whilst I do code in .NET as the need arises I don't use C++ etc. and can't see how this is relevant for my customers staff who are using windows explorer and the common file dialog etc. – Christopher Edwards Feb 9 '11 at 0:08
  • 1
    Ultimately, there is none. :-/ Sadly. – Chris K Feb 9 '11 at 3:35
  • @ChristopherEdwards You can create junctions to points lower in folder hierarchy. – Hubert Kario Nov 23 '11 at 23:59
  • @HubertKario Yes, but how would that help me? – Christopher Edwards Nov 28 '11 at 23:58
  • 1
    @ChristopherEdwards you could do a link c:\usr-data to `c:\Users\VeryLongUserName\LongFolderName` and tell him to use the former, but if he regularly names folders in 40-something characters then this won't help... – Hubert Kario Nov 29 '11 at 20:50

Microsoft now has an available fix for this beginning with Windows 10, which is explained in the Naming Files, Paths, and Namespaces MSDN article.

darthcoder already answered with details on the \\?\C: notation work-around, but there is now a registry key at HKLM\SYSTEM\CurrentControlSet\Control\FileSystem LongPathsEnabled (Type: REG_DWORD) which can be used to remove MAX_PATH limitations for a single system. The article also mentions support for Group Policy control at Computer Configuration > Administrative Templates > System > Filesystem > Enable NTFS long paths for organization or group-wide implementation if needed.

  • I've not had time for thorough testing, but I've seen mixed results with this solution so far, and can't confirm that this solves the problem for Windows [file] Explorer. – JimNim Apr 19 '17 at 13:57
  • 1
    This doesn't work in File Explorer because although the system and NTFS can handle long paths, Explorer cannot until it is itself re-coded. – ingyhere Dec 25 '17 at 18:50
  • PS, you will need to use one of the copy programs in this SO link on top of Explorer to actually make it work. – ingyhere Dec 25 '17 at 18:51
  • 1
    Good info! I will probably just stick to Robocopy in that case. – JimNim Dec 26 '17 at 5:59

protected by Sven Dec 26 '14 at 12:28

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.