I recently imported some source code for a customer that exceeded the maximum path limit of 256 characters. The paths in question weren't particularly meaningful, just pathologically* long, with redundant subfolders. To complete the migration, I renamed some of the parent folders to single character values.
This made me wonder: is 256 characters a reasonable limit for a path? And what's the longest path in my filesystem, anyway? I whipped up this little C# console app to loop through all the paths on my drive and report the longest one.
static string _MaxPath = "";
static void Main(string[] args)
{
RecursePath(@"c:\");
Console.WriteLine("Maximum path length is " + _MaxPath.Length);
Console.WriteLine(_MaxPath);
Console.ReadLine();
}
static void RecursePath(string p)
{
foreach (string d in Directory.GetDirectories(p))
{
if (IsValidPath(d))
{
foreach (string f in Directory.GetFiles(d))
{
if (f.Length > _MaxPath.Length)
{
_MaxPath = f;
}
}
RecursePath(d);
}
}
}
static bool IsValidPath(string p)
{
if ((File.GetAttributes(p) & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint)
{
Console.WriteLine("'" + p + "' is a reparse point. Skipped");
return false;
}
if (!IsReadable(p))
{
Console.WriteLine("'" + p + "' *ACCESS DENIED*. Skipped");
return false;
}
return true;
}
static bool IsReadable(string p)
{
try
{
string[] s = Directory.GetDirectories(p);
}
catch (UnauthorizedAccessException ex)
{
return false;
}
return true;
}
It works, but it's a bit more complicated than I wanted it to be, because
The longest path on a clean install of Windows XP is 152 characters.
c:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\S-1-5-18\ d42cc0c3858a58db2db37658219e6400_89e7e133-abee-4041-a1a7-406d7effde91
This is followed closely by a bunch of stuff in c:\WINDOWS\assembly\GAC_MSIL, which is a side-effect of .NET 2.0 being installed.
The longest path on a semi-clean install of Windows Vista is 195 characters:
c:\Windows\winsxs\ x86_microsoft-windows-m..-downlevelmanifests_31bf3856ad364e35_6.0.6000.16386_none_0041f38286aeaf07\ Microsoft-Windows-IIS-ClientCertificateMappingAuthentication-Deployment-DL.man
The longest path Microsoft created in Vista is 195 characters. But what's the longest path I can create?
The best I could do is 239 characters for folders, and 11 characters for the filename. Add in 3 characters for the inevitable "c:\", plus 6 slashes. That's a grand total of 259 characters. Anything longer and I got a "destination path too long" error.
The 259 character path limit I ran into jibes with the documented MAX_PATH limitation of the Windows shell:
The maximum length path (in characters) that can be used by the [Windows] shell is MAX_PATH (defined as 260). Therefore, you should create buffers that you will pass to SHFILEOPSTRUCT to be of length MAX_PATH + 1 to account for these NULLs.
If 259 characters plus a null seems like an unusually restrictive path limit for a modern filesystem like NTFS, you're right. The NTFS filesystem supports paths of 32,000 characters, but it's largely irrelevant because the majority of Windows APIs you'd use to get to those paths only accept paths of MAX_PATH or smaller. There is a wonky Unicode workaround to the MAX_PATH limitation, according to MSDN:
In the Windows API, the maximum length for a path is MAX_PATH, which is defined as 260 characters. A path is structured in the following order: drive letter, colon, backslash, components separated by backslashes, and a null-terminating character, for example, the maximum path on the D drive is D:\<256 chars>NUL.The Unicode versions of several functions permit a maximum path length of approximately 32,000 characters composed of components up to 255 characters in length. To specify that kind of path, use the "\\?\" prefix. The maximum path of 32,000 characters is approximate, because the "\\?\" prefix can be expanded to a longer string, and the expansion applies to the total length.
For example, "\\?\D:\<path>". To specify such a UNC path, use the "\\?\UNC\" prefix. For example, "\\?\UNC\<server>\<share>". These 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. Also, you cannot use the "\\?\" prefix with a relative path. Relative paths are limited to MAX_PATH characters.
The shell and the file system may have different requirements. It is possible to create a path with the API that the shell UI cannot handle.
Still, I wonder if the world really needs 32,000 character paths. Is a 260 character path really that much of a limitation? Do we need hierarchies that deep? Martin Hardee has an amusing anecdote on this topic:
We were very proud of our user interface and the fact that we had a way to browse 16,000 (!!) pages of documentation on a CD-ROM. But browsing the hierarchy felt a little complicated to us. So we asked Tufte to come in and have a look, and were hoping perhaps for a pat on the head or some free advice.He played with our AnswerBook for about 90 seconds, turned around, and pronounced his review:
"Dr Spock's Baby Care is a best-selling owner's manual for the most complicated 'product' imaginable -- and it only has two levels of headings. You people have 8 levels of hierarchy and I haven't even stopped counting yet. No wonder you think it's complicated."
I think 260 characters of path is more than enough rope to hang ourselves with. If you're running into path length limitations, the real problem isn't the operating system, or even the computers. The problem is the deep, dark pit of hierarchies the human beings have dug themselves into.
* ouch
What would be interesting is to actually hear someone from Microsoft comment as to why this limit still exists in their brand new Vista system even though the NTFS filesystem supports paths with 32000 characters.
They also said they completely reworked the explorer shell so I don't understand why they kept this limit.
Of course the obvious answer would be backwards compatibility but couldnt that have been solved by implementing this limit for programs that use the compatibility modes ?
This is actually starting to annoy me the more I think about it, Vista was supposed to be reworked almost ground up.
C#? WHO IS THIS? WHAT HAVE YOU DONE WITH JEFF?!?!?
:P
Kevin Dente on November 22, 2006 1:29 AMI've come across this on a previous job. The project was a knowledge management system that kept track of previous consulting jobs they worked on (think of it as the IT dept of "bob bob" from the movie Office Space (and watching that movie was actually a job requirement of that department)). It ran on asp classic (this was in 2001).
Upon migrating to a new server, we discovered that accessing some of the 70k documents popped up a dialog box with 3 boxes: domain, user, pwd. My first guess, because it was based on the first problem found was that some of the files were owned by the LOCAL admin account on the now turned off server. Oops, the ACL contained SIDs that the new server didn't know. Ok. Write a script to run through the file system, look for files with either an unknown owner or a local account and take ownership with a domain account.
Problem solved? Hah. Next it turned out that since many of the offices of this multinational insulting company used pesky ferrner words, those silly accents and slashes through letters caused good old yankee asp classic to have a barf. Next, run through and identify those pesky european words. That took care of a thousand or so files that were popping up the same dialog box with 3 boxes: domain, user, pwd.
Problem solved? Not a chance. By now the screaming idiots were screaming to fire my fanny perpendicular, until I found that the remaining files had paths well in excess of 250 characters. I think the record was near 600. Darn those Germans for having long long long words. And darn that company for having a multilingual standard for keeping them organized. And darn that loudest crazy screaming idiot for using the filesystem to rearrange the files into places that the web front end could not manage.
The explorer shell back in Win98 days could handle 32k long paths, but the standard API calls all used ANSI/ASCII calls instead of the "wide" ones that could use that newfangled unicode stuff.
My point, and I'm pretty sure I had one when I started, is that this problem isn't new, and it isn't limited to the .NET framework. It is one of those pesky limitations you end up with when the creators of your filesystem and OS make assumptions about everyone only using ASCII and that nothing outside of America exists at all.
Peter on November 22, 2006 1:52 AMIn any case it seems like a potential security hole to have variations in the API, would for example an antivirus program pickup a virus that hide in paths greater than 259+1 characters ?
I guess that would depend on which specific api calls the anitvirus scanner uses.
Moon/DL: One advantage to using a special C# program is that both of your methods builds a list in memory and then performs a sort and spits out the result. Problem with that is, when you run it against a 'file share' it will eventually kill your machine. Jeff's routine does 1 thing, holds the largest path it comes across in a variable and then displays it at the end and therefore has a consistent memory requirement of ~15MB. I would guess that the NIX command would require just as much memory as the Powershell command. I have been running the Powershell command now for a few minutes and it's using ~150MB. That's 10x the memory usage of the C# program.
Oh well even though the PS command is going to cripple my machine when I run out of memory at least it runs on 1 line. It just goes to show that the most efficient things are ones that are written for a single purpose. :D
Tim on November 22, 2006 2:36 AMI guess you could argue for "refactoring" if you reach the MAX_PATH much along the same lines as is good-practice when we write source code.
Last time I ran into this issue, was with some home brewed backup util which basically copies (selections) of my C, D partitions to a NAS unit (X). If X is set up to mirror these partition hierachies under, ie. X:\backup\week43\C-drive\ I run into trouble with certain .NET and various other files.
So I guess a 512 char path would not hurt, much like most have also violated the de-facto 80 char per line in source code files.
Casper Bang on November 22, 2006 3:21 AMHere's how my old abused iBook clocks in:
346 /Users/ejt/Library/Application Support/SyncServices/Local/clientdata/0063006f006d002e006100700070006c0065002e006900530079006e006300440055002e00450053004e003500310038003200310034003300370031/0063006f006d002e006100700070006c0065002e006900730079006e0063002e00760061006c00750065004d006900670072006100740069006f006e0054006f006900530079006e006300320032
I got a few more hits from 'SyncServices', and the next runners up are from system header files, e.g.:
231 /System/Library/Frameworks/IOBluetoothUI.framework/Versions/A/Resources/Japanese.lproj/Documentation/Reference/IOBluetoothServiceBrowserController/Classes/IOBluetoothServiceBrowserController/IOBluetoothServiceBrowserController.html
Terrier: I don't know what you're smoking, but have you noticed flash (aka non-moving-parts) drives still use hierarchical file systems? The file system is an abstraction -- it has nothing to do with the underlying hardware. If you think you have something better (like some vague concept where you "search" for everything, a la longhorn -- ewww) then we'd love to hear your bright idea.
And I love that the Windows crowd jumps on their little PowerShell thing, and then it runs into the API limitation and can't actually report the path if there's one longer than MAX_PATH. Hilarious. I wouldn't be surprised if the cygwin one did too. Don't even get me started on cygwin -- doesn't properly support gdb, can't do development on it, and the console UI sucks... a shadow of a real system.
Finally, I think it makes a lot of sense for applications to use the filesystem as a database... generally users don't need to go poking around in the internals of data directories, but if they do need to, it's a lot easier to navigate the file hierarchy than to try to find/write code to parse some custom file format that has all the various resources jumbled together in an unknown way.
Take Keynote bundles for instance -- looks and acts like a single file, but if you want, you can "View Contents" and swap an updated figure or play videos directly without ever having to launch the application. Very handy.
A lot of work has gone into allowing the filesystem to handle a variety of operations in an efficient way, and to then throw that away and try to reimplement your data storage as some kind of flat file just doesn't make sense. But I guess maybe it does if you live in a world of MAX_PATH idiosyncrasies.
Aaron G: your choice of trying to argue backward compatibility of *nix/OS X as a shortcoming is not the best point to pick.
Under *nix, since all the system sources are available, if you need compatibility you can compile the older libraries and have your binary blob link run against those. Voil.
Under OS X, Apple has bent over backwards to support older code -- most applications from OS 7 still ran in OS 9, and most OS 9 code will still run within "classic" in OS X. Not *everything*, but I'd say it's comparable to the odds that some Windows 3.1 app is going to run in Vista.
And looking ahead, if you notice my system headers are versioned -- OS X can retain the old libraries each time it is updated, so future upgrades won't be an issue with breaking older apps.
And perhaps you haven't used *nix in a while, but most software can be updated by a package manager, so people don't have to deal with Makefiles.
A final key is that both *nix and OS X have found ways to unshackle future development without utterly breaking backward compatibility. On its current path, Windows will just keep getting bigger and bloated as it tries to retain and work around every idiosyncrasy.
Ethan on November 22, 2006 3:55 AMOnce more, Jeff Atwood proves that UNIX Windows.
I can find the longest path on ~my~ filesystem by typing
sudo find / | awk '{print length($0) " " $0}' | sort -n | tail -n 1
I don't need to fire up a text editor and compiler to do that; in fact, I don't need help from Visual Anything. And I don't need to tell people to keep their paths short because I run a two bit operating system.
Sailor Moon on November 22, 2006 4:17 AMOh yeah... That shell command finished running on my Mac Mini -- it took just two minutes, it probably helped that it's got a 7200 rpm drive. Here's my longest filename:
298 /Users/luna/restore/usagi/Library/Application Support/SyncServices/Local/clientdata/0063006f006d002e006100700070006c0065002e005300610066006100720069/005400720061006e0073006c00610074006f0072002d004c006500670061006300790043006f006e006400750069007400420075006e0064006c00650050006100740068004b00650079
It's a crazy binary blob, but so what?
Maybe it's just me, but on Linux I like filling up directories with filenames like:
windowssucks
windowssuckS
windowssucKs
windowssucKS
windowssuCks
windowsssCkS
...
WTF? Why are you coding in C# now? :(
Anonymous on November 22, 2006 4:32 AMEthan: Under *nix, since all the system sources are available, if you need compatibility you can compile the older libraries and have your binary blob link run against those. Voil.
Try telling that to my dad. You will get an even more glazed look staring back at you as the one that I had when I read that statement. USERS SHOULD NOT HAVE TO COMPILE SOURCE CODE!
Tim on November 22, 2006 4:40 AMTim -- I agree that Jeff's program uses less computer resources than mine. On the other hand, mine took less human time to write: It took me 30 seconds to write a first draft; I discovered that it didn't handle filenames with spaces correctly, which took another 30 seconds to fix.
My program is fast enough, at least on my system: it scans about a half a million files on my Mac in two minutes.
Yes, there are more efficient algorithms than sorting for finding the largest member of a set. In the Unix style, I could write a small filter that implements such an algorithm in awk, perl or C; then I've added a function to my library that I can compose to make efficient pipelines to do other jobs.
My point is that any good Unix admin can knock off scripts like this in a few minutes. It makes our jobs a lot easier. Powershell will bring this kind of capability to Windows admins, and that's a good thing.
Sailor Moon on November 22, 2006 4:48 AMSailor Moon, since you are a troll I guess I shouldn't answer but once again nix nerds seem to fail to understand that there are several ways of doing things.
You could just as well install something like Windows Powershell and get the same thing without creating a program for it. Or you could create a simple script.
Did you really think you need visual studio to do anything in windows, surely you are not that ignorant ?
In this case he chose to do it this way, what is the problem ? The problem is only that you need to reiterate to yourself that your poor choice of system is somehow superior.
Sailor Moon, you are indeed very clever. In spite of the fact that the code is clearly a console app, you still made a point of the word visual in the title. Clearly you are ignorant of the facts and have taken the "Unix systems are better by default" approach that so many *nix fanboys seem to be constantly bugging me with. I find it interesting that you find the idea of the visual aspect so appauling, I'd love to know what your actual objection to the process is. I also wonder if you've ever written anything in C# or .NET to actually provide a basis for your objections.
One day we might live in a world where people can just use the right technology for the right job without this rabid brand loyalty that everyone seems to have. Why not just accept that its possible to live in a world where you use Windows for some things and *nix or anything else you desire for other things. To say anything in relation to Windows is inferior (or conversely that anything in another system is superior) simply because you do or don't like the system is just ignorant and a somewhat counterproductive attitude.
Greg Poole on November 22, 2006 5:17 AMSucks to be a windows user. The longest path on my system here at work (Linux) currently is 338 characters. Maybe you should go get yourself a real OS.
Chris on November 22, 2006 5:21 AMI have a couple of questions regarding the Unicode vs local drive limits. At work we mimic the region/territory structure of our real estate portfolio on a shared drive for document storage purposes (document management is a battle being fought). Some of the folder structures can be quite lengthy due to the fact that it mimics our CRM system so the application can go find folders for leases, etc. Our help desk has told them that their path had to be less then 205 characters long, and certain files wouldn't open for them until they shortened the path. Now for me, I never "mapped" a drive and connect via UNC path but didn't seem to have the same problem. Is UNC the same as the Unicode path, since UNC originally came from UNIX?
Tim on November 22, 2006 5:23 AMLots of people that can't read properly apparently, like pointed out in the article the NTFS system can support much longer paths so this limit is imposed by the api, probably because of backwards compatibility.
I am suprised though that they let this creep into Vista as well, this decision must have been because of backwards compatibility. It also raises questions about how much they actually changed during the past five years of development of Vista.
Tim: Your dad doesn't care about backward compatibility with some ancient custom "business critical" cruft. It's a moot point.
It's not like Average Joe is going to want Netscape 4.07 or some other random outdated program. They want the most up to date stuff at the time of installation so they can remain compatible with *current* resources for as long as possible.
What *is* an issue for Joe Average is then having to buy faster hardware to upgrade their software, which is what Vista will do. New versions of Linux and OS X don't bloated hardware requirements each time a release comes out, and to the contrary, OS X has run better on my same hardware with each revision.
The people who care about running some specific old binary POS, but moving to newer/faster hardware which isn't supported by the old system the POS was written for, is for stuff like accessing some internal corporate resource that only works with a particular program that no one can update. And in this situation, you'll have a big company with people who *do* understand how to compile, and they'll set up the libraries once and then remotely distribute a package. So in this case, Average Joe doesn't even see an installer, much less have to compile anything.
Ethan on November 22, 2006 6:04 AMI think this depends on your perspective. If you follow Microsoft's lead by plopping your source code into \Document and Settings\UserName\My Document\Visual Studio 2005\Projects, you immediately lose 72 or so characters from MAX_PATH. If you also follow Microsoft's lead by naming your projects Company.Product.Project, you lose another long length from MAX_PATH.
If you want to solidify the issue, drop Microsoft's Enterprise Library source into the Visual Studio 2005\Projects folder and count again. You'll find the path length well exceeds the 260-character limit, Visual Studio can't compile the project, and SyncToy can't synchronize the project folder to offline storage.
KL: The same thing in C/C++/C# (via mono) on UN*X would of course not be smaller, the point I was trying to convey, was that he had to write the rather long C# program, because he had not hat the power of a unixish (mingw under Windows) environment "at his command".
My post was not intended to be a Windows flame.
sigi on November 22, 2006 6:20 AMWell, some open source systems like Hipergate have a Corporate Library system based on subdirectories, and they have a nice way of naming diretories, something like mydir~00001, of course you can see paths like
"C:\jakarta-tomcat-5.0.28\webapps\hipergate\opt\storage\domains\2049\workareas\c0a801bf10080e106af1000009cb90d5\ROOT/DOMAINS/TEST/TEST_SHARED/ISO~00001/COMERCIAL~00001"
the "c0a801bf10080e106af1000009cb90d5" is the owner's primary key of the document, well whit 4 or 5 levels of Hierarchy plus the file's name you have a big problem, is very common have troubles with six months to one year of use.
Mario Arias on November 22, 2006 6:22 AMNo need for a war between Unix and Windows: Moon's oneliner works on cygwin.
Paul Houle on November 22, 2006 6:23 AMMany years ago I tried to teach a non-computer user about trees and folders. Since they had never had the pleasure of using DOS commands like "cd" and typing lots of filepaths, it was hard.
But, there is the temptation to mingle the concepts of "how much filename and pathname do I reasonably need" with "how many levels of hierarchy actually make sense?". 15 levels of 20-character filepaths will apparently break things. Is this unreasonable? Is it retarded to do this?
Trees and folders force a physical hierarchy, and like any man-made system this has its pros and cons. Would allowing 5000 character path names make a better world? Probably not, but situations such as foisted on Jeff by his customer certainly make you wish for a few more than 259.
Steve on November 22, 2006 6:32 AMThe path limitation has bitten me a number of times, usually because of generated paths. For example, Oracle's "Workspace Drive" client (basically a WebDav-based IFS) creates cache directories constructed from the local cache directory plus the remote directory path.
The local cache directory is placed in the Microsoft-approved location ("C:\Documents and Settings\%username%\Application Data\Oracle\ODrive\cache"), which chews up about 80 characters. The server portion of the path (with the fully-qualified server domain name and a few directories to get to the share) chews up another another 50 or so. Then a somewhat-deep directory structure, which was perfectly valid when it was created on the original SMB-shared server, pushed the path length over 260 characters.
The odd thing was that the Oracle client had no trouble creating these directories (probably using the UNC trick you mention), but when I tried to upgrade the client and the installer choked when it tried to delete the old cache directories.
In the end, I had to resort to the old SUBST.EXE utility to map a drive halfway down the long path, delete everything from that mapped drive, then unmap the drive and delete the rest before I could upgrade.
So no--in the age of mechanically-generated paths, 260 characters isn't enough for everybody.
Tim Lesher on November 22, 2006 6:44 AMI've recently come across this with a bug report on some code that I'm working on, and it sucks, big time.
First, the wonky unicode workaround does not work in .NET. Period. The max filename limit for .NET 2.0, a proper 21st century programming framework released in 2005, is 260 chars.
Second, on XP, the path for user documents belonging to a certain type of application is:
c:\documents and settings\username\my documents\application projects\
which is about 70 chars. Worse, on some of our users systems, they have:
\\server\users\department\documents and settings\username\my documents\application projects\
which is almost 100.
From there, projects are saved in their own directory with the name given to a project. For the projects our users have, they generally include stuff like the name of their client, the year and month of the project, and a meaningful description of the project in the project name. e.g.:
MegaCorp contract for frobbing the gromits - Sep 2006
There's another 50+ characters there. Project names of 80 characters aren't /that/ rare and project names of 120 characters exist.
That's over 200 characters. Now we have files in that directory and some subfolders. Users create files with meaningful names too.
You can hit that 260 char limit pretty darn quick. But the only thing we can tell our users is not to use nice long descriptive names for things, despite the fact that Windows is supposed to support long filenames.
Thanks to Moon's script, here's mine:
300 /Users/carlmanaster/Music/iTunes/iTunes Music/Coviello, d'Intino, Matteuzzi, Ricciarelli _ Gelmetti - Orchestra della RAI di Torino/Rossini_ La Gazza Ladra - Milan 1817 - Pessaro 1989 (Disc 2)/2-06 Stringhe e ferri da calzette; Ecco la gabbia; Andiam tosto; Eccovi, omiei signori; E sopra e sotto.m4a
Which I've got to acknowledge is a fairly long filename, but I didn't do anything elaborate to create it. I'm not a fan of using filenames to store database information, but obviously some people are.
Carl Manaster on November 22, 2006 7:04 AMAll hierarchical file systems are dead-ends. That includes blessed *nix and all flavors (with whatever limits) derived from it. Programmers apparently live in a world of infinite play time. Real people just want their documents. This is the last hardware hurdle we must cross: the limitations of physical IO. Once storage has no moving parts hierarchical file systems will go the way of the dinosaur.
Terrier on November 22, 2006 8:01 AMMaximum path length is a horrible joke. It is unbelievable that MS can't fix this after so many years, and that the author of this blog accept this stupidity as a good thing.
I guess the next post will be how the various invalid characters in Windows file system are not really needed and actually a great idea :-)
nirs on November 22, 2006 8:05 AMHere's a one liner for Windows Powershell:
ls -r C:\|sort {$_.fullname.length}|select -l 1|select fullname
Thanks to "dreeschkind" on the microsoft.public.windows.powershell newsgroup.
Without wrapping the result:
ls -r -fo C:\|sort {$_.fullname.length}|select -l 1|select fullname|fl
The longest path I have is
C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\Business Intelligence Wizards\LanguageProjects\JSharp\JSharpDWWizards\ADOMDStoredProcedure\Templates\1033\assemblyinfo.jsl
Which is 202 characters.
At last, *nix vs. Windows condenses to actually slapping them on a table and getting a ruler. Why did it take this long?
Si on November 22, 2006 8:35 AMSince when the linux version matters for a program to work? As far I'm concerned it depends on the libs used to build the program. So you can build software in a new version of a linux distro and it will run on an older version. So I don't know what your talking about.
-rn
rn on November 22, 2006 8:44 AMSi: I just wanted to show that this is entirely possible to do on a "one liner" in powershell.
An argument you often hear from the nix people is how powerful their shell is, we'll, I would argue that with Windows Powershell the most powerful command line is actually on Windows these days.
But those commands are not from me but courtesy of "dreeschkind" on the powershell ng. Unfortunately I havent had tim to learn powershell yet.
KL on November 22, 2006 8:56 AMThe Maximum path is a serious limitation of the dotnet framework. I was flabergasted when I first encountered the problem with a scanning tool I wrote. 99% of the time, it is not an issue, but one application routinely makes files that exceed this limitation ...
Internet Explorer.
It's cache files tend to be long enough that I cannot access it's files using the dotnet framework - I end up calling the API directly with the \\?\ nomenclature to get a file handle, and then use that handle toaccess the file... a big pain in the *.
The only files I have encountered larger than the limit are created by MS programs, although a new network folder naming policy at my workplace is sure to change that
\\some_server\some_device\OrgUnit\OrgUnit\Division - Office\Folder Name - Person Responsible For Content\SubFolder - Person Responsible For Content\etc
I've run up against this a number of times when I was working with InstallShield. They create a large amount of folders on their projects - all with nice, long descriptive names.
Because of this, instead of saving them in the traditional "Microsoft approved" place of C:\Documents and Settings.... I had to save them in a folder directly on the root directory of C.
Nic Webb on November 22, 2006 9:16 AMKL -- way to go with that Powershell script.
I ran Moon's script on a Fedora Core 6 system, and found that (i) the longest path was shorter than any other OS reported yet, and (ii) it's a file from .net!
144 /usr/lib/mono/gac/System.Runtime.Serialization.Formatters.Soap/1.0.5000.0__b03f5f7f11d50a3a/System.Runtime.Serialization.Formatters.Soap.dll.mdb
To Anonymous: You noticed that too?
To Jeff: WTF? (Why the flip?) Glad to see you on the Dark Side...
[soapbox]
To all the Win/Nix combatants: Whatever gets the job done. If one tool doesn't work, get the right one. When the tool doesn't work, don't bash it 'til it's dead cuz it aint gonna die. Someone else will pick up that tool and use it perfectly for their purpose. Just cuz it didn't work for you doesn't mean it won't work for someone else.
I've used Mac in the past. It worked for what I was doing. I've used Linux (still do) and it works for what I was trying to do. I've used Windows DAILY since Win 3.0 and it does what I need it to do.
It's what I preach to my son (and my wife sometimes...) use the right tool for the job.
The same goes to all you VB vs. C# vs. C++ vs. [insert programming language here]. It's just a tool. I've used a lot of them in varying degrees. Each has its own little niche that accomplishes a task. Use what suits the task.
[/soapbox]
To all in the USA: Have a great holiday weekend!
John Baughman on November 22, 2006 9:40 AMUsing the Powershell cmd, this one is 248 characters long:
C:\Temp\OldPC\PROJECTS\PIVOTAL\TEST\Documentation\6 - IPG Retail\08 Training\IPG Leasing System - Retail\Documentation\Retail Final\Property Management\Training Presentation - Prop Mgmt and Operations Getting Started_Contact_Opportunity_Mgmt(1).ppt
The key area where the MAX_PATH limitation becomes a major problem is for applications that use the file system as a database (which is an entirely reasonable thing to do). In this case, the hierarchy is not something the end user directly controls or interacts with, but in this day and age an application should be able to have pretty much an arbitrary hierarchy depth without having to deal with API hacks.
MAX_PATH is an ugly API wart that we may have to live with for a long time due to backwards compatibility (which is important, too).
mikeb on November 22, 2006 10:31 AMHere's the final version for Powershell which searches all drives:
gdr -p FileSystem|%{gci -r -fo $_.root}|%{$m=0}{$f=$_.fullname;if($f.length -gt $m){$n=$f;$m=$f.length}};$n
It will print some errors on unmounted usb and cd/dvd drives but it works great.
Still courtesy of "dreeschkind" on the powershell ng.
KL on November 22, 2006 10:31 AMWhen i use this powershell, i get error messages when the path is too long, but it doesent show which are too long.
Is it possible?
Jan-Erik
Jan-Erik on November 22, 2006 11:10 AMThe main reason MAX_PATH is 260 is because a lot of developers are goddam idiots who genuinely think (to this day) that using a #define PATH_LENGTH 256 at the top of their projects is a WONDERFUL idea. After all, 256 is a nice round number in binary, and who in their right mind would ever use more than 256 characters in a path? Doesn't (random tweak site) say paths are limited to 256?
Until the application dies from a buffer overflow as soon as it tries to open that file that's 257 characters long.
Mac and unix apps are not immune from this! After all, there are idiots writing software for any system. I've seen it happen occasionally (rarely, who deals with paths that long every day?), and I've seen it in code, open source and otherwise, more often than I can count. An OS feature that crashes half the software on it as soon as they come across the feature isn't an automatically great idea.
(btw, there are fully native win32 ports of unix tools, no cygwin required, as well as win32 variants of common unix functionality. Not sure why any unix guru wouldn't have them otherwise, unless they hadn't been forced to use windows for any reason since NT was hot.)
Foxyshadis on November 22, 2006 11:11 AMI ran into a similar problem with one of our source trees the other day when I tried to copy it to a build directory that had a few more characters. I wrote a similar app, but one thing I added was a count of how many dir/files were of each length 1-300char.
At least on my system with a lot of hidden by the OS stuff in local settings, and .net stuff I have hundreds of paths that are over 200, and plenty in the 240+ range.
Can you refactor for smaller paths, sure, is that always the right idea. absolutely not. sometimes a descriptive hierarchy is a good thing.
Rob on November 22, 2006 11:20 AMFor most UN*X users a quick
/ # find . | wc -L
should do the trick. You just gotta love a unixish environment after comparing the one-liner to the C# code ;-)
sigi on November 22, 2006 11:51 AMJan-Erik: I'm afraid I don't know Powershell well enough but the command only prints the longest path, since the max limit is in the api I would assume powershell hits the same limits.
I think you can probably catch the error but I can't provide an example.
sigi: What is it that is so hard to understand that he chosed to make a program of this ? The post wasn't about "one liners" although I showed this can be done as a one liner with Windows Powershell as well.
Would the C/C++/C#(yes it's possible) program on nix be smaller ?
So I was using Powershell to check for a long path on one of our network drives, but alas:
Get-ChildItem : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
Tim on November 22, 2006 12:37 PMWhy does Shell blog say that MAX_PATH includes the terminating null to contradict MSDN, which says it includes the terminating NULL? Dude you gotta read between the lines!
karl on November 23, 2006 3:27 AM@KL: "I would argue that with Windows Powershell the most powerful command line is actually on Windows these days. [...] Unfortunately I havent had tim to learn powershell yet."
ROFL. Funniest comment in the thread. Please wiki hypocrite chap.
2 cents. No matter if it was a *nix or windows or whatever, 260 character paths are reminiscent of '640k is enough memory'. It's a ridiculously low value. Maybe vista compatibility should have been done with an abstraction layer so that old crap API's could be done away with for good. Old programs - old api. New programs - new api. Short term pain means long term gain for Vista because old the programs will still need updating regardless.
We should treat the file system as a database and realise that we need more than just filename + path. I like descriptive names and directories, but properties-Advanced is far too kludgy and i can't convince my mom to do it. She for some reason likes to call files things by meaningful names. consider
'/documents and settings/mom/my documents/letters/personal/2005/medical/knee problems/the letter i sent to dr spock about tenderness after vermont ski trip'
vs
'ltr2drabtsrknee'
or better yet
'letter(1).doc'
I don't think hierarchies are dead, nor will they ever be - until world robot domination that is - 'cause our robot masters don't need them.
At least we have google desktop.
Dr 1.0 on November 23, 2006 6:00 AMDr 1.0: learn it and you'll be suprised, it contains way more powerful features since you can manipulate any object on the system and the whole .net framework from the command line.
Can you do that with bash ?
In any case, this discussion is old, only the trolls left and people like me that jsut has to answer the trolls.
The limit is there because of compatibility, end of story, I guess if longer file paths is all you ask from a system then by all means use nix system.
The easiest thing to do is to do is to make a filename only so long, and then use metadata to store the rest (can metadata be applied to folders?). Of course, you could just get a real OS... like SuSE Linux.
gjsmo on November 23, 2006 7:29 AMYes he does, it's called the Windows Powershell
http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx
Maximum path lengths turn the file system into a
leaky abstraction
totally agree. if the user is given enough rope to hang themselves by other systems, then newer system shouldn't break on it.
let's not be presumptuous.
oh, 256 as a limit is just arbitrary and wrong, don't get me started. but no, i'd never use that much.
lb on November 24, 2006 6:41 AM"And looking ahead, if you notice my system headers are versioned -- OS X can retain the old libraries each time it is updated, so future upgrades won't be an issue with breaking older apps."
Windows also supports this, it's called side by side execution.
Jim on November 26, 2006 2:14 AMWanting 32,000 character paths isn't about usability; it's about breaking getting rid of a bothersome, low-visibility, programmer assumption.
I really don't know of a programmer that gives a lot of thought about path lengths until the end of the project (if even then). When talking about an apps "future compatability" this isn't something that comes up. If the client wants to organize a massively long and tangled heirarchy of data, we'll just tell tech support to say "Don't do that" when they call for help. We may blame the user for the problem, but fundamentally it's our assumption that this is a non-issue.
While 256 character path lengths are far more than I'll ever need in my work, API's that supported 32,000 character length paths throughout would completely remove any worry about that assumption from my mind.
William on November 29, 2006 2:03 AMI ran
"gdr -p FileSystem|%{gci -r -fo $_.root}|%{$m=0}{$f=$_.fullname;if($f.length -gt $m){$n=$f;$m=$f.length}};$n"
and it turned up
"D:\Library bringhomes\1\files\Google Image Result for http--www_zdnet_co_uk-i-z-rv-2006-09-vista-rc1-i6_jpg_files\0,390
24180,39282492,00_files\reviews;tn=5;tnm=5;tek=0;te=2;pw=100;tc=EEEEEE;th=70;to=v;tsw=0;tcp=0;ta=left;tva=bottom;szs=39
0x13;ptile=1;ord=1903"
which is 259 characters (counted with VB 1.0). Thanks for reminding me that that folder exists! (My 'net access used to be at our library. I would bring stuff home to look at later - especially webpages, some of the navigation systems in websites are sooo coool.
I must comment about Windows Powershell. Finally Windows can teach me that 'cd\' won't work anymore and I have to do 'cd /'. However, I am what one might call a UI designer-graphic designer-programmer multi so I like to see that an interface is well written and works well, so I like things to, well, look nice. Upon downloading and installing this "PowerShell" (and the .NET framework) I immediately right-clicked the titlebar and hit 'Defaults'. No matter what I changed I could not get 80 lines, Lucida Console and all that changed. It defaults to the BSOD blue for the background and the 'DOS white' for the foreground. I don't know if PowerShell will replace CMD or if it will be just a tool.
By the way, if anyone actually does find a way to change PowerShell's settings then post or mail dav7[at]bigpond[dot]com.
I mentioned VB 1.0 before. THAT was one VERY GOOD programming language. 564KB, nothing else (really) required! It would fit on a floppy! You don't have to try and be Mr. 10 Diplomas to write something in VB 1.0 (very much unlike VB Express!). Did I mention the fact that the single "dependancy" was only 264KB (I think)? That was the age when code and UI equally mattered and people paid attention to detail.
Unlike today...
In my last post I mentioned whether PowerShell would replace CMD or if it would be a tool. I forgot to explain that I meant that if PowerShell wasn't customizable then the chances are that I wouldn't enjoy using it and would have to go back to CMD (the standard Windows commandline).
The single dependancy was indeed 264KB and was named VBRUN100.DLL. I find it very fascinating that you actually don't find this file included with ANY Windows version (even Win95 98).
David on November 30, 2006 3:41 AMI wonder if good old DOS with the long names converted to 8.3 format hits that limit as well. I mean: would it be possible to copy a file to a 259 char path when you reduce it to its 8.3 format.
So instead of trying to copy a file with XP to:
C:\Documents and Settings\Some really long and overly complex path that is no use to anyone whatsoever etc etc etc until the 259th character\
use DOS to copy to:
C:\documen~1\some~1\
Hmmm gonna try that when I find some time between typing replies to blog entries like these ...
Paul on December 6, 2006 2:05 AMSystem.IO.PathTooLongException
Hello,
Ever got this error?
The specified path, file name, or both are too long. The fully qualified
file name must be less than 260 characters, and the directory name must be
less than 248 characters.
Since the .NET Framework does not support long filenames :-(
I had to write a library that calls the WIN32 API and wraps those functions
like System.IO.
I have a solution to your problem!
Delimon.Win32.IO replaces basic file functions of System.IO with long path
names support for characters up to 32,767 Characters
So bye bye MAX_PATH problem
A new version is available now:
- Added file/folder date changes
- Added attributes support
- Added Reading and Writing files
A Win32Explorer is also available that lets you access long filenames in
Windows
You can download my library here:
http://www.delimon.be
REM Throw this in a BAT file and run it. Windows Sucks.
@MD C:\BLOCK
@C:
@CD C:\BLOCK\
:TWO
@IF ERRORLEVEL 1 GOTO THREE
@MD 0
@CD 0
@GOTO TWO
:THREE
@MD C:\X
@MD C:\T
@CD \..
@XCOPY C:\BLOCK\0 C:\T /E /Y /Q
:FOUR
@XCOPY C:\BLOCK\0 c:\X /E /Y /Q
@REN C:\T\0 1
@MOVE /Y C:\T\1 C:\X\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
@XCOPY C:\BLOCK\0 C:\T /E /Y /Q
@REN C:\X\0 1
@MOVE /Y C:\X\1 C:\T\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
@GOTO FOUR
PowerShell is nice -- took long enough though. Wonder what kind of a rich scripting community and history windows will develop(rhetorical). And scripting on UNIX -- we'll just use python or perl if bash can't handle it. By the way, we have those multitudes of little tools that are so useful for scripters to call upon.
Excuse me, I've got to reboot into (my little used and thus less decayed) windows to help my grandfather learn how to build his vb program, which is spitting out an error on his (oft used and thus very buggy) windows computer about how it can't publish to a file path over 260 char long -- even though he told it to publish to a ~30 character c:/programs/volume/ filepath.
Windows, great product -- keep up the backwards compatibility instead of making upgrades simple. And by the way, we're running beryl and pico on linux, so much for the claim that we don't have backwards compatibility -- we just also have forward compatibility!
The average windows user can't keep their computer virus free -- this is that same average user you're always claiming can't use linux. Give him kubuntu and see if he floats -- he will.
By the way, OpenOffice does everything MS Office does (and much better than Office on Mac), GIMP does photoshop, and we have an answer to everything.
Our product is better, our ethics are better, and our goals are more sensible.
For the average user, day by day *n?x gets easier...Staying up, virus free, and installing the software that would be of any use to a normal user is as easy as a click on Add/Remove programs, which can actually install programs from the internet (IMAGINE!) -- it actually adds programs that aren't on the cd in your drive!
Most users just need a computer that doesn't get buggy and that creates .doc's, does spreadsheets, and surfs the net -- ubuntu linux, for one, does that out of the box and so frigging easy a toddler could do it. WINDOWS DOESN'T -- it'll have viruses by the end of the week and there's no free software to handle it. (Unlike Linux.)
Also, for the computer enthusiast, true involvement with makefiles and compilation should be enjoyable (what are you going to do once you've installed the word processor or image processor, write a book and illustrate it? You're the computer guy!) ;)
The obvious choice for the vast majority of computer users, the Current MS | Future OpenOffice-er / surfer / communicator, is the one that doesn't get buggy and crashy and that runs top-grade productivity software -- AND IS FREE.
Any programmer who doesn't do *n?x is missing out on so much of what has made programming and the languages what they are. To bash *n?x and (ba)sh is to belittle those who've given birth to that which you most love (where the hell do you think they got the idea for your windows scripting?)
Here's one: How can you guys, coders, live with yourselves for actually giving any emotional energy towards supporting a company that was responsible for a memo discussing their goal of destroying cross-platform Java.
Where do you want to go? Nowhere, they want to stifle.
a rose by any other on January 20, 2007 11:52 AMI don't understand why should you be limited to 256/260 characters when there is enough space on the disk to accomodate the path?!
Why have a limit when you can afford to not be limited?!
Andrei Rinea on July 4, 2007 3:03 AMLOL at all the OS flaming...
I'm concerned a virus/spyware could create a folder longer than the OS can see/scan.... Possible?
Another issue, I have a customers PC with paths too long, when I try to open the folder way,way down the path, windows does nothing!!!. At least DOS reports file name is too long.
How can I retrieve data from within that folder if I cannot access the folder or copy it up the tree?
As I dont know the importance of the data in that folder, I don't know how serious an issue this make turn out to be.
Oh, and aren't ADS a great idea for hiding stuff!
Just another point, the win registry also has key name limitations, longer keys are hidden!!! but still active/usable - very dangerous problem for spyware, etc.
Ah the wonderful world or windows, pity I dont have a couple of years to learn unix:)
josh on July 13, 2007 1:28 PMI think unix has a max path limitation of 1024 character.
You still hit it from poor .cshrc coding where people always prepend but never clear the PATH variable... so every time you resource your environment it doubles the size of your path.
Then there's the stupidly long path names to releases of tools. Each tool added to your path adds an absurd number of characters (better to have one directory on your path with symbolic links or shell wrappers to the direct tool).
engtech @ IDT on September 19, 2007 11:58 AMI see no reason WHY we should have restrictions...elements of the Big Brother???...you shall not go to the Ball..."you will not exceed 260 characters" WHY this is a flexible system as we are always told I read other defending the NONE right to restrict...come on!!! in the land of Geek we pride ourselves on going byond what we are allowed....not to sit there and defend...
"my longest sting or my longest file name is.....BULL"
grow up and smell the roses...this is a straight laced shackling of the system WINDOWS GONE MAD WITH POWER....
so please, please do not defend it...it's against all we beleive in...
A 50 year old geek and proud of it??
I've felt Eamon Nerbonne's pain myself. However, in my case, it was a .pdf file downloaded with uTorrent. The file downloaded correctly but could not be opened by double-clicking from the shell. I had to rename the file a shorter length to open it. That inconsistency is scary for developers writing file system operations in programs.
Craig Boland on January 9, 2008 7:25 AMTo delete a chain of subdirectories that are too long, I retrieved a copy of ROBOCOPY and deleted them easily. I used the syntax: robocopy dummydirectory bad_directory /E /NOCOPY /PURGE . The dummydirectory was a temporary subdirectory that I created that had one small file in it. ROBOCOPY deleted thousands of subdirectories that had been created by a rogue program that was recursively creating new subdirectires.
It was the only probram or tool that could delete them as deep as they were. Hope this helps someone.
Bob Coss on January 23, 2008 6:11 AMYes, lots of products have the limitation of 256.
But finally there are third party solutions that just allows to work with files keeping their real long paths.
I’ve been using the following library that resolves it. It is not free, but comes with samples on C# C++ VB and working code.
http://www.abtollc.com/product1733992.html
Peter
Peter on January 30, 2008 10:27 AMBob Coss, thank you very much for your advice! Worked like a charm.
Leonard W on June 10, 2008 10:09 AMI use audio files to study Japanese on my iPod. I have a native record a sentence, then I name the file the text of the sentence I am practicing. Some sentences are long, so the filename is appropriately long. The name scrolls along the screen on my iPod as I listen, letting me practice reading the chinese characters, listening, and pronunciation. I moved from XP to Vista recently, and I keep getting errors related to the length of the path now. It is truly annoying - like when I try to move something to the trash but it won't let me because the filename is too long, or when I try to mess with things in my music manager because it makes directories that use the artist name and the album title and song title in a nested fashion - also sometimes making the length of the path too long.
Grrrrrrrrrrrrrrrrr!
Jay on August 31, 2008 11:54 AM239 /mnt/mp3/mp3/Metal/Bal Sagoth/Battle Magic (128 kbs)/06 - The Dark Liege of Chaos Is Unleashed at the Ensorcelled Shrine of A'Zura Kai (The Splendour of a Thousand Swords Gleaming Beneath the Blazon of the Hyperborean Empire - Part II).mp3
Jakub Narbski on September 1, 2008 6:01 AMls -r -fo C:\|where {$_.fullname.length150}|sort {$_.fullname.length}|select -l 1|select fullname|fl
I am testing this script on my c:\ drive and get access denied on some folders and the script fails, how can I skip those directories and let the script run?
I administrate network in a company, we produce socks. One of our users named the file something like this: customer-ord_no-item-size-color.doc, (of course I hide the original names, which were much longer) ... when i saw it, i said to the user and what did you write inside? 100 pairs ? because there is no other information missing on filename.
Just to say the problem is more often between keyboard and chair.
Most classical music listeners who use iTunes want filenames longer than 260 characters, so that we can distinguish variations on music in the song title. (Did this work fine in XP? I don't recall any problems there, but when I upgrade to Vista I have to rename *all* my hundreds of titles, one by one? WTF?!)
E.g., these are some illustrations of filenames:
Beethoven Cellosonaten, Op. 5; Variations-03-Variations for cello piano in F major on Mozart's 'Ein Mdchen oder Weibchen,' Op. 66 Variation IV.mp3
Franois Couperin - Pices de Violes-15-Douzime Concert deux Violes, ou autres instruments L'unisson_ Air (gracieusement, et lgrement)
J.S. Bach Italian Concerto French Overture [L'Oiseau-Lyre] - Christopher Rousset-03-Duetto, for keyboard No. 1 in E minor (Clavier-bung III No. 23), BWV 802 (BC J74)
Publius on January 6, 2009 2:28 AMArtificial constraints on a system are seldom, if ever, a good thing. Arguments about why we *shouldn't* need longer names are missing the point.
Having said that I will say that the whole file and folder metaphor is generally accepted to have been failure. Interesting to me is that it never worked, even when it was real files in real folders it was a common office joke to query, 'what was that filed under?' It's all about context and we tend to have more than one for most things we think about.
Curt on January 8, 2009 11:10 AMI see some people have created API for money - has anyone seen some completed classes where we can see the source code?
If you google long path blog part 2 - Microsoft provide a starter for 10...
tur13o on January 14, 2009 8:03 AMProbably the sense of the post is deeply right: if you hit some limits the rest of the world happily live with, probably you should rething the developmnet strategy.
But my tiny experience shown me that the less assumption you take writing something, including putting hardcoded limitations, the less probably it will get screwed when
- word changes
- machines change
- typical users change
- most commom tasks change
which, if the software has a sizeable userbase, happens nearly daily.
I.e. IBM did a great choiche building OS/400 on a virtual 128 bit system; probably they will never hit hardcoded limitations imposed by this choice (maybe neither if they had go for 64 bit), but the point is that while x86-64 software and system is still not mainsteam (2009), they were able to migrate a lot of architectures without the tedious need to rewite/retest a lot of software.
Just for not having bound themselves to hardcoded limits coming from making too many assumptions.
Just wanted to thank Bob Coss for his comments above. I had looked everywhere for a way to delete a dir that ended up having 7000+ nested dirs inside it. robocopy did the trick.
pathtoolongarrrrgh on February 20, 2009 9:58 AMhmmm. let's make the maximum number of characters 256.
I read all your comments and they were fantastic.
Now, if microsoft would stop acting like some top-down behemoth and write software we can use.
yet another dumb idea on May 11, 2009 1:25 PMI actually do work for Microsoft and the primary reason for the limit is indeed compatibility. There are a lot of old programs that have MAX_PATH (260) as limit. As soon as the Explorer shell "fixed" the limitation, then all of those program will buffer overflow when the long path is passed in.
NTFS *can* support 32K paths. Lower level Win32 APIs can support 32K paths. Explorer and the old cmd shell *choose* not to for backward compatibility reasons. (and maybe others I am not aware of). I have no idea why .Net framework imposes the same restriction... that seems a little wierd..
Anonymous on June 18, 2009 12:24 PMpackage removedirs;
import java.io.File;
public class RemoveDirs {
File rootDir = null;
public RemoveDirs(File rootDir){
this.rootDir = rootDir;
}
public void walk(File dir, int depth){
System.out.println("Depth:" + depth);
if (dir.isFile()){
dir.delete();
} else if (dir.isDirectory()){
File files[] = dir.listFiles();
if (files.length == 0){
System.out.println("del: " + dir.getAbsolutePath());
dir.delete();
if (depth > 1){
if (dir.getParentFile().listFiles().length == 0){
walk(dir.getParentFile(), depth -1);
}
}
}
for (File file: files){
walk(file, depth+1);
}
}
}
public void walk(){
walk(rootDir, 0);
}
public static void main(String[] args) {
RemoveDirs rd = new RemoveDirs(new File("c:/cygwin/work/core"));
rd.walk();
}
}
// Run as admin (vista), make sure your absolutly sure its the correct directory before running. Java 1.4 or higher
I disagree. The maximum path length in windows is a serious - and seriously annoying - issue with all kinds of nasty side effects.
Maximum path lengths turn the file system into a leaky abstraction: when you move a directory into another directory, it _is_ possible to sidestep the path-length limitation, and create files that can't be read by any program, whether administrator-privileged or not, without modifying the directory structure.
The maximum path length isn't such an issue when design a hierarchy up-front, but it is when you combine existing hierarchies, something you'll inevitably do.
I wrote a slightly longer argument hereof on my website.
Eamon Nerbonne on February 6, 2010 9:52 PMTo the Mac/nix trolls:
Your OS doesn't have these "unbelievable" limitations because they don't even attempt to maintain any sort of backward compatibility. Try running a System 6/7 app on Tiger. Or a RedHat 6 binary on Fedora. Good luck. In fact, forget about backward compatibility, there's no attention paid to compatibility of any kind. Even a minor update can totally break an app or library.
But I forgot, we'll just hand users the source code and get them to compile it, and that will eliminate all those nasty compatibility issues, right? Because every user knows how to compile source code and loves hunting around for the 38 dependencies and 9 kernel patches that they need. And every user knows how to fix a makefile that was never fully tested. And last but not least, every program worth having OBVIOUSLY comes as Open Source, except for MS Office and Adobe Photoshop and uh, pretty much every other popular app. And the drivers for most new hardware and gizmos.
Don't kid yourselves, kids - for every "feature" of Linux (which I used daily for 3 years) I prefer over Windows, I can count 10 more that drive me nuts. Mac fanboys may have it a little easier, but that's only due to the hard work of 3rd-party software vendors who, coincidentally, don't share your philosophy and are only supporting you to make a few extra bucks.
Aaron G on February 6, 2010 9:52 PMI don't see what's so outrageous about having long file names. If the user wants to name files something meaningful to themselves who's to say they shouldn't use their computer that way? For that matter, for small enough notes, who's to say the user can't just put ALL the data in the file name? I can hear the shreiks now, but short of outdated technical reasons is there any reason to prohibit users from doing this? Filename (and location) is just one of myriad metadata about a blob of data.
I tend to agree that hierarchical filesystems are going to start disappearing because organizing everything in a single axis of taxonomy is inefficient (to humans) (same goes for symlinks, which are possibly worse), but while they are still around brain-damage restrictions from the 1980s shouldn't be restricting how users use their system.
Aaron H on February 6, 2010 9:52 PMIn PowerShell:
dir -path "c:\" -recurse | where { $_.fullname.length -gt 150 } | sort-descending fullname.length | select fullname.length, fullname -first 1
Not sure if that where clause helps performance; it might not be necessary.
Jon Galloway on February 6, 2010 9:52 PMAh, I see KL provided the PowerShell answer a while ago. I like mine better, though - the where clause seems to make it run more than twice as fast on my box (160GB, dual 2.8, 3GB ram). My query took 4 minutes 47 seconds, KL's is still running at 13 minutes.
I figured a baseline of 150 characters made sense since Jeff found that 152 was the longest path on a fresh install.
Here it is in a more terse format:
ls -r -fo C:\|where {$_.fullname.length150}|sort {$_.fullname.length}|select -l 1|select fullname|fl
System.IO.PathTooLongException
Yes I got it, from Jeff Atwood's program.
System.IO.PathTooLongException on February 6, 2010 9:52 PMI just hit this problem organising some MP3s. My hierarchy is only a few levels deep but one or two albums had some very long names and track names. One track in particular, took its path over the limit after the album was moved, and that left me with a file that I could not even rename or move from Windows Explorer (Explorer just refused to do anything with the file).
The workaround was to rename the lower-level folders so they weren't so long, and that is how it should have been from the start. However, the fact remains that I managed to blow the 260 character limit just by moving a few folders around, and the results were pretty unpredictable. For example, I couldn't find the total running time for the album, and MS Synctoy simply skipped half the files it was meant to be backing up after hitting this file (that is how I managed to find the culprit).
-- Jason
Jason Judge on February 6, 2010 9:52 PMI think the critical point is that there is no actual limit to the paths that can be created, just a limit in some Win32 APIs. Those APIs have to stay the same for backwards-compatibility purposes. OK. So old programs won't be able to read long files.
So the logical thing to do is create a new interface without the restriction that new code can use. There is a way to handle paths with lengths up to the filesystem's limit, but it doesn't support things like relative paths. Microsoft doesn't promote its use and doesn't in fact use it in its own software.
This problem could go away eventually if simply new and useful API functions without the path limit were created, used throughout Microsoft's software, and promoted for use in all new software. If it had happened around the year 2000 most people would be blissfully unaware today (honestly, WinNT4 would have been a good time to do this, but it's never too late). If it happens tomorrow maybe we'll put this to rest by 2020. But it won't happen tomorrow. When I turn 40 I'll still be dealing with the path limit and I won't even have a flying car. Some future.
Al Dimond on November 22, 2010 10:25 AM
All Problems have ONE solution and that is:
www.longPathTool.com
Path too long.
Error cannot delete file: cannot read from source file or disk
Cannot delete file: Access is denied
There has been a sharing violation.
Cannot delete file or folder The file name you specified
is not valid or too long. Specify a different file name.
The source or destination file may be in use.
The file is in use by another program or user.
Error Deleting File or Folder
Make sure the disk is not full or write-protected and that the file is not currently in use.
Path too deep.
alan.larky on December 21, 2010 5:02 AMI had the similiar problem and finally I found solution:
www.tooLongPath.com
I had the similiar problem and finally I found solution:
www.longPathTool.com
I had the similiar problem and finally I found solution:
www.tooLongPath.com
I had the similiar problem and finally I found solution:
www.sipVoipSdk.com
I had the similiar problem and finally I found solution:
www.sipVoipSdk.com
Silverlight definitely needs long file paths:
C:\Documents and Settings\reallylongerusername\Local Settings\Application Data\Microsoft\Silverlight\is\qzm2cwh3.bk0\xvzol3cm.540\1\s\wbt3ggyazzgf42xkvmzkumxhseqylr2brzmpatqodms5hg2z1jaaahaa\f\888b19e95-cf6b-4b0c-9588-1a8ea8ce8ca4-c4b19e95-cf6b-4b0c-9588-1a8ea8ce8ca4.db
You're left with around 50 characters once that completely OTT IsolatedStorage path is created.
Chris S. on March 2, 2011 3:49 AMwithout drifting through the massive amount of boring trolling by users of various operating systems ....
The biggest problem, is that a not inconsiderable amount of those 256 characters are 'taken' from you by default paths, for instance with Visual Studio "C:\Users\user.name.domain\Documents\Visual Studio 2010\Projects" and THEN if you have a sensible naming structure you use something akin to the project namespace so "yourapp.company.com", which is then used twice, once for 'solution' level folder and once for each project under it (whatever namespace they use).
Only THEN do you actually get to the content folders of your project.
To get anywhere near useful you have to ignore all the windows 'friendliness' anyway and create yourself short paths from drive root like 'C:\bill\projects'
Bah!
Saves1uktivo on September 8, 2011 12:50 AMThe comments to this entry are closed.
|
|
Traffic Stats |