Tuesday, August 19, 2014

The .NET Framework has LongPath (> MAXPATH) support? Yes! Well, kind of, it's private...

Did you know the .NET Framework has classes to handle "Long Paths" (i.e. Paths > MAXPATH)? How long have we been hoping for that? A decade+ (Look at my XRef below, been blogging about this since 2004... sigh). So when I saw them, I jumped for joy. Finally! Woot!

The problem is is that we can't use them! sigh...

They are private and not exposed for us to use, i.e. they are only .NET internal usage. And guess what? Had to chuckle at this, the .NET team uses them in the IsolatedStorage system. They handle their possible long path issues, but don't share. Didn't they go to kindergarten? Sharing is good! LOL

Think I'm smoking dope? Check this out...


image image 



.NET Framework Team, you guys are such a tease...  :)

Lets hope that maybe we'll see this, or something like it, publicly one day. We can only hope. In the mean time, there's a number of libraries you can use. I use AlphaFS mostly and while it's been around for a while, it's still alive and updates and fixes are still being checked in.

UPDATE (8/20/2014)

On the train into work today I realized that the LongPath.cs is focused on local drive only. It doesn't support file shares (i.e. \\?\UNC\...). Which makes since given its current use case, isolated storage (which is always local).

If you're spelunking that its source, keep this implementation limitation in mind...


Related Past Post XRef:
MAX_PATH got you down? Zoom over to the Zeta Long Paths project

AlphaFS v1.5 Released (think "The 'Long Path' IO support the BCL doesn't yet have..." or "Don't 'W' [Wide/Unicode API/etc] P/Invoke your Path API's when AlphaFS has done it already for you..." or "How I learned to love and use Volume Shadow Service paths from .Net")
AlphaFS – Some Max_Path, Transactional NTFS, hard links, and more .Net System.IO.File/Path/Directory Help (alpha)

Powering into RoboCopy with the PowerShell RoboCopy clone, RoboPowerCopy (which even includes Long Path support...)

The Long Path for the BCL Team
Introduction of the BCL CodePlex project (code samples, previews, prototypes, etc from the BCL team) – Includes “Long Path” library direct from the BCL Team (think “Breaking out of MAX_PATH”)

Subsytem for Unix (SUA) Utilities and SDK For Windows 2008 and Vista SP1
The PInvoke tool you've been looking for all this time... the "PInvoke Interop Assistant"
Using GetFileAttributes to Test for File Existence
Unicode Path Fun...

No comments: