Today's project is one that I've been following years and have used a number of times. It helps you solve what has started to become an issue, MAX_PATH...
While NTFS supports folder paths up to 32K long, Windows and .NET have yet to expose that, instead keeping with the legacy MAX_PATH length, 260 characters. And let me tell you, 260 isn't what it used to be...
There are WinAPI's that you can use via PInvoke, but before you go there, maybe someone else has already done the heavy lifting?
The file system support in .NET is pretty good for most uses. However there are a few shortcomings, which this library tries to alleviate. The most notable deficiency of the standard .NET System.IO is the lack of support of advanced NTFS features, most notably extended length path support (eg. file/directory paths longer than 260 characters).
- Support for extended length paths (longer than 260 characters)
- Creating Hardlinks
- Accessing hidden volumes
- Enumeration of volumes
- Transactional file operations
- Support for NTFS Alternate Data Streams
- Accessing network resources (SMB/DFS)
- …and much more!
What does AlphaFS provide?
AlphaFS provides a namespace (Alphaleonis.Win32.Filesystem) containing a number of classes. Most notable are replications of the System.IO.File, System.IO.Directory and System.IO.Path, all with support for the extended-length paths (up to 32000 chars), recursive file enumerations, native backups and manipulations with advanced flags and options. They also contain extensions to these, and there are many more features for several functions.
Another thing AlphaFS brings to the table is support for transactional NTFS (TxF). Almost every method in these classes exist in two versions. One normal, and one that can work with transactions, more specifically the kernel transaction manager. This means that file operations can be performed using the simple, lightweight KTM on NTFS file systems, through .NET, using the interface of the standard classes we are all used to.
AlphaFS also contains some NTFS security related functionality (in Alphaleonis.Win32.Security), providing the ability to enable token privileges for a user, which may be necessary for eg. changing ownership of a file.
The library is Open Source, licensed under the MIT license.
Excited about your latest masterpiece, but filled with anger and fear when you find out that a .NET path can still be too long for your app.
So, this is exactly how I felt, mostly angry.
I had written the best next-gen-file-explorer only to find out that it kinda sucked when I reached that dreaded
PATH TOO LONGerror.
Just as you did, I searched the net and searched the net and searched until I came across AlphaFS 1.5.
Wohoo! I was SO happy to see that people actually had put together this marvelous library
that in the end my next-gen became old-skool because I completely abandoned it and totally focused on AlphaFS.
The result of that is presented here today!
We are proud to present to you version 2.0 of AlphaFS.
“When the Path is too long, one’s journey may end.
Observing the First, as Alpha moves on.”
Highlights of version 2.0
- AlphaFS is now distributed primarily at NuGet.
- Because of major inspiration, some backward compatibility may have been broken. Forgive us for this, but we’re sure you’ll quickly recover.
- Implementations of major .NET classes (File, Directory and Path, …) up until .NET 4.5.
- Implemented a brand new file systems enumerator.
- Added support for working with files and folders with a trailing dot or space.
- Added support for AlternateDataStreams.
- Added support for accessing network resources, like SMB and DFS shares.
- The repository was moved to GitHub, to allow for third party developers to more easily contribute to the library.
The source is available and there's even doc's!
In short, this System.IO replacement will help you break away from MAX_PATH, nevering worrying about it again...
Also it's important to note that AlphaFS works great with PowerShell. Check this out for more details, https://github.com/alphaleonis/AlphaFS/wiki/PowerShell
Page thumbnail curtsey of Forsetius (Get it? Io as in System.Io... ;)
Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.