93

As I understand it, the limitation of 255 characters in a file path is a Windows limitation. What is the reasoning for this? If so, has this been resolved in Windows 7?

In our continuous integration practices, we often have deeply nested project structures and it would be extremely useful to be able to go beyond 255 characters. Right now we are somewhat forced to structure our projects in such a way as to not hit this artificial ceiling.

The Matt
  • 6,618
  • 7
  • 44
  • 61
  • 3
    @DavidHeffernan But that 260 includes the null character at the end and the `C:\\` at the beginning, so only 255 characters are usable. – Aaron Dufour Apr 24 '13 at 16:59
  • 2
    @DavidHeffernan I was mistaken. Microsoft often quotes the length as 256, which is what you get when you subtract properly, rather than 260, which is technically the limit. – Aaron Dufour Apr 24 '13 at 18:21
  • 5
    This problem enrages me. It is still present in windows 8.1. I can't seem to move my files about, even though SOMEHOW the file was created in the first place. If you find some way to create files with 255+ file path names you can totally mess up someone's windows machine. – Automatico Apr 25 '15 at 13:12
  • According to Jeremy Kuhne the problem is being worked and may soon have a solution. See this video. https://www.youtube.com/watch?v=ZppqEMegCAA – J Edward Ellis Jul 14 '16 at 19:29
  • Question is about Windows 7, but anyway, Windows 10 does have am option to turn on long paths for some applications. For more details check out this answer: http://stackoverflow.com/questions/27680647/does-max-path-issue-still-exists-in-windows-10 – quasoft Sep 18 '16 at 13:12

5 Answers5

45

See http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx

This explains that Unicode versions of Windows APIs have higher limits, and how to enable that.

crashmstr
  • 28,043
  • 9
  • 61
  • 79
Drew Hoskins
  • 4,168
  • 20
  • 23
  • 14
    But a word of warning: There's a bunch of code (mostly 3rd party system utilities and the like) that doesn't play well with longer paths. You may have issues with that if you start using longer paths. – Larry Osterman Jul 04 '09 at 15:15
  • 2
    Is this article correct? I did a simple teste with both Windows Explorer and Windows Command Prompt in Windows 7 and I'm not able to create file paths with over 260 characters. Has Microsoft not updated these applications to use the Unicode versions of the Windows APIs? – Templar Aug 20 '12 at 20:58
  • 7
    Unfortunately Windows Explorer on Windows 7 x64 is still subject to this path limit. This gives the impression that the entire operating system has not overcome this limit, when really it is just Windows Explorer that has not been updated to work with longer paths. It is possible that a 3rd party file manager using the latest APIs could get around this. Ultimately whether a program appears to hit the path limit will depend on whether that program uses the newest APIs on Windows. – user1445967 Jul 28 '13 at 18:09
  • 2
    It isn't a question of "newer" or "older" APIs. You only get long path support if you explicitly ask for it, and Explorer doesn't do so, presumably for the obvious reason: compatibility with existing third-party applications. – Harry Johnston Apr 26 '15 at 01:58
  • 9
    -1 - A link to a potential solution is always welcome, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline. http://meta.stackoverflow.com/tags/link-only-answers/info – Russia Must Remove Putin Dec 01 '15 at 17:41
21

You can get around that limit by using subst if you need to.

Joshua
  • 40,822
  • 8
  • 72
  • 132
  • 5
    more info here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/subst.mspx?mfr=true – Chris B Dec 16 '10 at 10:03
  • 2
    Or robocopy which is built in to Windows, based on this answer, http://stackoverflow.com/questions/29865863/how-to-move-folder-files-with-path-names-255-characters-in-windows-8-1?lq=1 – KAE Nov 24 '15 at 17:18
  • 5
    You should demonstrate how and provide a link to relevant documentation. -1 – Russia Must Remove Putin Dec 01 '15 at 17:43
  • 3
    While I upvoted, I agree an example would be useful: `subst E: D:\TESTDATA\4B871B~1\4B871B~1\4B871B~1\4B871B~1\4B871B~1\4B871B~1\4B871B~1\4B871B~1\4B871B~1\4B871B~1\4B871B~1\4B871B~1\4B871B~1\4B871B~1\4B871B~1` That got me around a path that was 500 chars deep. The reason for the ~1s is the way Explorer formatted the path. – Adam Marcionek Dec 04 '15 at 14:28
  • 1
    A similar solution would be using [junctions](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365006%28v=vs.85%29.aspx), either through a [shell extension](http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html) or through [mklink](https://technet.microsoft.com/en-us/library/cc753194%28v=ws.11%29.aspx) Example: ```mklink /J C:\newdir C:\some\really\long\path\``` – Charles Grunwald Jun 26 '16 at 04:37
14

Workarounds are not solutions, therefore the answer is "No".

Still looking for workarounds, here are possible solutions: http://support.code42.com/CrashPlan/Latest/Troubleshooting/Windows_File_Paths_Longer_Than_255_Characters

user1767754
  • 23,311
  • 18
  • 141
  • 164
  • 1
    Core elements of windows including powershell, windows explorer shell, and cmd utilities like del still can not handle paths that exceed 250 characters, and no workaround fixes the fact that core Microsoft technologies do not handle long paths, as of 2016. The short answer here is until Microsoft gets its collective behinds in gear, there is little we can do. – Warren P May 02 '16 at 16:06
4

@Cort3z: if the problem is still present, this hotfix: https://support.microsoft.com/en-us/kb/2891362 should solve it (from win7 sp1 to 8.1)

Chad Levy
  • 10,032
  • 7
  • 41
  • 69
ale.com
  • 91
  • 1
  • 2
1

From Windows 10 version 1607, the limitation has been removed by setting a registry key

https://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx?f=255&MSPPError=-2147217396#maxpath

chedabob
  • 5,835
  • 2
  • 24
  • 44