Click here to Skip to main content
Click here to Skip to main content

Zeta Long Paths

, 25 Jun 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
A .NET library to access files and directories with more than 260 characters length


This article describes a library that provides several classes and functions to perform basic functions on file paths and folder paths that are longer than the "MAX_PATH" limit of 260 characters. 


All .NET functions I came across that access the file system are limited to file paths and folder paths with less than 260 characters. This includes most (all?) of the classes in the System.IO namespace like e.g. the System.IO.FileInfo class.

Since I was in the need to actually access paths with more than 260 characters, I searched for a solution. Fortunately a solution exists; basically you have to P/Invoke Win32 functions that allow a special syntax to prefix a file and allow it then to be much longer than the 260 characters (about 32,000 characters).

The Library

So I started writing a very thin wrapper for the functions I required to work on long file names.

These resources helped me finding more: 

I started by using several functions from the BCL Team blog postings and added the functions they did not cover but which I needed in my project. 

Currently there are the following classes: 

  • ZlpFileInfo - A class similar to System.IO.FileInfo that wraps functions to work on file paths
  • ZlpDirectoryInfo - A class similar to System.IO.DirectoryInfo that wraps functions to work on folder paths 
  • ZlpIOHelper - A set of static functions to provide similar features as the ZlpFileInfo and ZlpDirectoryInfo class but in a static context 
  • ZlpPathHelper - A set of static functions similar to System.IO.Path that work on paths

Using the Code 

The project contains some unit tests to show basic functions. 

If you are familiar with the System.IO namespace, you should be able to use the classes of the library.

For example, to get all files in a given folder path, use the following snippet:

var folderPath = new ZlpDirectoryInfo( @"C:\My\Long\Folder\Path" );

foreach ( var filePath in folderPath.GetFiles() )
    Console.Write( "File {0} has a size of {1}",
        filePath.Length );

When using the functions, please do not encode the paths with the long path syntax (like e.g. \\?\C:\my\path) but pass them as normal paths like c:\my\path or \\myserver\myshare\my\path. The library itself decides whether a path has to be converted and does it automatically. 


This article quickly introduced a library to deal with long file names when accessing files and folders. 

Please note that the library currently is limited in the number of provided functions.

I will add more functions in the future, just tell me which you require, below in the comments section of this article. 


  • 2014-06-25 - Also available on GitHub and on CodePlex.
  • 2012-08-10 - Added several new methods.
  • 2011-10-10 - Fixed an error in ZlpFileInfo.Exists.
  • 2011-03-30 - Fixed a resource leak.
  • 2011-03-27 - Fixed an issue with WIN32_FIND_DATA.
  • 2011-02-22 - Added more functions.  
  • 2011-01-31 - Added functions MoveFile and MoveDirectory
  • 2010-03-24 - Added functions to get file owner, creation time, last access time, last write time.
  • 2010-02-16 - Maintenance release. 
  • 2009-11-25 - First release to  


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Uwe Keim
Chief Technology Officer Zeta Producer Desktop CMS
Germany Germany
Uwe does programming since 1989 with experiences in Assembler, C++, MFC and lots of web- and database stuff and now uses ASP.NET and C# extensively, too. He has also teached programming to students at the local university.
In his free time, he does climbing, running and mountain biking. Recently he became a father of a cute boy.
Some cool, free software from us:
German Developer Community  
Free Test Management Software - Intuitive, competitive, Test Plans. Download now!  
Homepage erstellen - Intuitive, very easy to use. Download now!  
Send large Files online for free by Email
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

QuestionZeta Producer Pinmvp.dan.g.17-Sep-14 20:34 
AnswerRe: Zeta Producer PinsitebuilderUwe Keim17-Sep-14 20:37 
GeneralRe: Zeta Producer Pinmvp.dan.g.17-Sep-14 21:57 
QuestionIs there a file rename function? Pinmemberdatsspeed14-Feb-14 1:23 
AnswerRe: Is there a file rename function? PinsitebuilderUwe Keim14-Feb-14 2:59 
GeneralRe: Is there a file rename function? Pinmemberdatsspeed14-Feb-14 3:09 
GeneralRe: Is there a file rename function? Pinmemberdatsspeed2-Mar-14 21:45 
GeneralRe: Is there a file rename function? Pinmemberjohannesnestler25-Jun-14 4:03 
GeneralMy vote of 5 PinmemberMauricevh24-Jan-13 2:21 
GeneralMy vote of 5 PinmemberHope W Lam9-Jan-13 5:27 
BugPInvokeHelper.MAX_PATH bug Pinmemberdrussilla5-Dec-12 4:51 
GeneralMy vote of 5 PinmemberJF201510-Aug-12 6:12 
Suggestionx64 Support PinmemberRichard Y9-Apr-12 13:07 
GeneralRe: x64 Support PinsitebuilderUwe Keim9-Apr-12 19:23 
GeneralRe: x64 Support PinmemberZac Greve1-Jul-12 9:21 
GeneralRe: x64 Support Pinmembermrdance6-Aug-12 23:51 
GeneralRe: x64 Support PinsitebuilderUwe Keim9-Aug-12 19:59 
QuestionZlpDirectoryInfo PinmemberMember 860610429-Jan-12 22:26 
Questionadd a column for file/path length in windows explorer PinmemberMember 435848925-Aug-11 12:13 
GeneralMy vote of 5 Pinmemberveki-peki27-Mar-11 9:33 
GeneralRe: My vote of 5 PinsitebuilderUwe Keim27-Mar-11 9:34 
GeneralBug: ZlpIOHelper.GetFileLastWriteTime() PinmemberHorscht200526-Mar-11 14:15 
GeneralRe: Bug: ZlpIOHelper.GetFileLastWriteTime() PinsitebuilderUwe Keim26-Mar-11 19:41 
GeneralRe: Bug: ZlpIOHelper.GetFileLastWriteTime() PinmemberHorscht200527-Mar-11 11:33 
GeneralRe: Bug: ZlpIOHelper.GetFileLastWriteTime() PinsitebuilderUwe Keim30-Mar-11 10:04 
GeneralRe: Bug: ZlpIOHelper.GetFileLastWriteTime() PinmemberHorscht200531-Mar-11 6:28 
GeneralThe system cannot find the file specified Pinmemberwehadfun22-Mar-11 19:03 
GeneralRe: The system cannot find the file specified PinsitebuilderUwe Keim22-Mar-11 20:53 
GeneralRe: The system cannot find the file specified Pinmemberwehadfun23-Mar-11 18:51 
GeneralRe: The system cannot find the file specified PinsitebuilderUwe Keim23-Mar-11 20:58 
GeneralRecursive Directory Deleting PinmemberMike Fed23-Feb-11 7:33 
GeneralRe: Recursive Directory Deleting PinsitebuilderUwe Keim23-Feb-11 8:03 
GeneralRe: Recursive Directory Deleting PinmemberMike Fed23-Feb-11 8:33 
GeneralMy vote of 5 PinmemberJV999923-Feb-11 1:10 
GeneralMy vote of 5 PinmemberSledgeHammer0122-Feb-11 12:10 
QuestionNew feature required PinmemberHorscht200522-Feb-11 10:53 
AnswerRe: New feature required PinsitebuilderUwe Keim22-Feb-11 11:08 
GeneralRe: New feature required PinmemberHorscht200522-Feb-11 11:12 
GeneralRe: New feature required PinmemberMarcus Kramer22-Feb-11 11:33 
GeneralRe: New feature required PinsitebuilderUwe Keim22-Feb-11 11:40 
GeneralMy vote of 4 PinmemberR. Hoffmann8-Feb-11 9:36 
GeneralRe: My vote of 4 PinsitebuilderUwe Keim22-Feb-11 11:08 
GeneralZeta Long functionality requested Pinmembermichaeldjackson20-Mar-10 14:58 
GeneralRe: Zeta Long functionality requested PinmvpUwe Keim21-Mar-10 21:10 
GeneralRe: Zeta Long functionality requested PinmvpUwe Keim23-Mar-10 20:15 
GeneralRe: Zeta Long functionality requested Pinmembermichaeldjackson24-Mar-10 3:19 
GeneralAdditions Pinmembermichaeldjackson22-Feb-10 14:47 
GeneralRe: Additions PinmvpUwe Keim22-Feb-10 19:33 
General PinsitebuilderUwe Keim5-Jan-10 2:57 
GeneralLong awaited Pinmemberreisenklaus26-Nov-09 11:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150327.1 | Last Updated 25 Jun 2014
Article Copyright 2009 by Uwe Keim
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid