I have come up against this problem a few times at inopportune moments:
- trying to work on open source Java projects with deep paths
- Storing deep Fitnesse wiki trees in source control
- An error trying to use Bazaar to import my source control tree
Why does this limit exist?
Why hasn't it been removed yet?
How do you cope with the path limit? ... and no, switching to linux or Mac OS X is not a valid answer to this question ;)
As to how to cope with the path size limitation on Windows - using 7zip to pack (and unpack) your path-length sensitive files seems like a viable workaround. I've used it to transport several IDE installations (those Eclipse plugin paths, yikes!) and piles of autogenerated documentation and haven't had a single problem so far.
Not really sure how it evades the 260 char limit set by Windows (from a technical PoV), but hey, it works!
More details on their SourceForge page here:
and release notes:
IMPORTANT NOTE: For this to work properly, you'll need to specify the destination path in the 7zip "Extract" dialog directly, rather than dragging & dropping the files into the intended folder. Otherwise the "Temp" folder will be used as an interim cache and you'll bounce into the same 260 char limitation once Windows Explorer starts moving the files to their "final resting place". See the replies to this question for more information.
From Windows 10. you can remove the limitation by modifying a registry key.
You can mount a folder as a drive. From the command line, if you have a path
C:\path\to\long\folder
you can map it to drive letterX:
using:The question is why does the limitation still exist. Surely modern Windows can increase the side of
MAX_PATH
to allow longer paths. Why has the limitation not been removed?Through API contract, Windows has guaranteed all applications that the standard file APIs will never return a path longer than
260
characters.Consider the following correct code:
Windows guaranteed my program that it would populate my
WIN32_FIND_DATA
structure:My application didn't declare the value of the constant
MAX_PATH
, the Windows API did. My application used that defined value.My structure is correctly defined, and only allocates
592
bytes total. That means that i am only able to receive a filename that is less than260
characters. Windows promised me that if i wrote my application correctly, my application would continue to work in the future.If Windows were to allow filenames longer than
260
characters then my existing application (which used the correct API correctly) would fail.For anyone calling for Microsoft to change the
MAX_PATH
constant, they first need to ensure that no existing application fails. For example, i still own and use a Windows application that was written to run on Windows 3.11. It still runs on 64-bit Windows 10. That is what backwards compatibility gets you.Microsoft did create a way to use the full 32,768 path names; but they had to create a new API contract to do it. For one, you should use the Shell API to enumerate files (as not all files exist on a hard drive or network share).
But they also have to not break existing user applications. The vast majority of applications do not use the shell api for file work. Everyone just calls
FindFirstFile
/FindNextFile
and calls it a day.You can enable long path names using PowerShell:
Another Version is to use a Group Policy in
Computer Configuration
/Administrative Templates
/System
/Filesystem
:It does, and it is a default for some reason, but you could easily override it with this registry key:
See: https://blogs.msdn.microsoft.com/jeremykuhne/2016/07/30/net-4-6-2-and-long-paths-on-windows-10/