a companion discussion area for blog.codinghorror.com

Filesystem Paths: How Long is Too Long?



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 :frowning:
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

You can download my library here:


REM Throw this in a BAT file and run it. Windows Sucks.

@MD 0
@CD 0
@MD C:\X
@MD C:\T
@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
@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


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!) :wink:

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.


I 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?!


LOL 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:)


I 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).


I 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.


To 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.


Yes, 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.




Bob Coss, thank you very much for your advice! Worked like a charm.


I 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.



239 /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


ls -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)


Artificial 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.


I 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…


Probably 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.