ZetaLongPaths 1.0.0.41

There is a newer version of this package available.
See the version list below for details.
dotnet add package ZetaLongPaths --version 1.0.0.41
NuGet\Install-Package ZetaLongPaths -Version 1.0.0.41
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ZetaLongPaths" Version="1.0.0.41" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ZetaLongPaths --version 1.0.0.41
#r "nuget: ZetaLongPaths, 1.0.0.41"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ZetaLongPaths as a Cake Addin
#addin nuget:?package=ZetaLongPaths&version=1.0.0.41

// Install ZetaLongPaths as a Cake Tool
#tool nuget:?package=ZetaLongPaths&version=1.0.0.41

Zeta Long Paths

A .NET library to access files and directories with more than 260 characters length.

Introduction

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

If you want to use the additional convenience functions of this library with normal non-long paths, and in both .NET Core and Full, please see my new .NET Standard package Zeta Short Paths.

Quick usage

Background

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.

Among others, 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.FullName, 
        filePath.Length );
}

Other libraries

Beside this library, there are other libraries available for accessing longer paths:

Personally, I've used none of these libraries. When I started developing this library either none of the other libraries existed or I have poorly searched.

According to user comments, the Long Path library is rather restricted in terms of functionality; the Delimon library is apparently much more powerful than my library.

Conclusion

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.

I'm using the library in several widely used real-life projects like our Content Management System (CMS), our Test and Requirements Management tool and our Large File Uploader, so the library should be rather stable and reliable.

History

(The full history is always available in the commits list).

  • 2016-09-27 - I've just discovered that .NET 4.6.2 now supports long paths natively. So if you are using my library you probably don't need it anymore if you target .NET 4.6.2 or above. (Or maybe it is not yet ready for prime time)
  • 2016-08-12 - First introduction of a .NET Core library (.NET Standard 1.6). See this NuGet package.
  • 2016-07-28 - Added functions to deal with short (8.3 "DOS") and long paths.
  • 2014-07-18 - Added functions like MoveFileToRecycleBin() to delete files and folders by moving them to the recycle bin.
  • 2014-06-25 - First release to GitHub. Also available at The Code Project.
  • 2012-12-21 - Added an NuGet package.
  • 2012-09-20 - Some very few methods added. Stability release.
  • 2012-08-10 - Added several new methods.
  • 2011-10-11 - Fixed an issue inside ZlpFileInfo.Exists.
  • 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 CodePlex.com.

(This is not a complete history; only the milestones are noted)

Product Compatible and additional computed target framework versions.
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on ZetaLongPaths:

Package Downloads
OsTestFramework

Library provides functionallity for managing remote Windows machine, like Copy/Delete/Read File, Execute elevated command, Read registry, WMI operations, etc.

Relativity.Import.Client

The Relativity import API client .NET package.

Codenesium.BuildCopyLib

none

StealFocus.MSTestExtensions

StealFocus MSTestExtensions package.

EbbsSoft.NETStandard.ExtensionHelper

A .NET Standard Extension Helper.

GitHub repositories (4)

Showing the top 4 popular GitHub repositories that depend on ZetaLongPaths:

Repository Stars
n00mkrad/text2image-gui
Somewhat modular text2image GUI, initially just for Stable Diffusion
Ulterius/server
[WIP] Ulterius™ server where all the magic happens :rocket: :feelsgood:
TeslaFly01/SmartSqlT
🔥🔥🔥 SmartSQL 是一款方便、快捷的数据库文档查询、导出工具!该工具从最初支持CHM文档格式开始,通过不断地探索开发、集思广益和不断改进,又陆续支持Word、Excel、PDF、Html、Xml、Json、MarkDown等文档格式的导出。同时支持SqlServer、MySql、PostgreSQL、SQLite等多种数据库的文档查询和导出功能。
UweKeim/ZetaResourceEditor
Free multilingual, parallel .NET resource file editing
Version Downloads Last updated
1.0.17 16,029 6/11/2023
1.0.16 14,900 6/21/2022
1.0.15 547 6/14/2022
1.0.12.41 40,657 2/21/2022
1.0.11.41 525 2/17/2022
1.0.10.41 5,749 1/25/2022
1.0.9.41 792 1/19/2022
1.0.8.41 723 1/19/2022
1.0.7.41 672 1/13/2022
1.0.0.41 29,192 9/24/2021
1.0.0.40 1,659 8/17/2021
1.0.0.38 17,864 12/12/2020
1.0.0.37 18,920 3/17/2020
1.0.0.36 5,601 3/5/2020
1.0.0.35 717 3/5/2020
1.0.0.34 1,007 2/7/2020
1.0.0.33 639 2/7/2020
1.0.0.32 18,653 10/10/2019
1.0.0.31 1,193 9/10/2019
1.0.0.29 7,724 5/13/2019
1.0.0.28 5,104 3/1/2019
1.0.0.27 9,535 10/16/2018
1.0.0.26 905 10/16/2018
1.0.0.25 7,341 9/9/2018
1.0.0.24 31,048 5/22/2018
1.0.0.23 39,239 12/7/2017
1.0.0.22 1,088 12/5/2017
1.0.0.21 9,393 11/20/2017
1.0.0.20 4,039 10/26/2017
1.0.0.19 1,451 10/21/2017
1.0.0.18 29,936 5/17/2017
1.0.0.17 6,400 3/30/2017
1.0.0.16 11,865 3/7/2017
1.0.0.15 51,875 2/8/2017
1.0.0.14 16,965 8/13/2016
1.0.0.13 1,114 8/12/2016
1.0.0.12 1,176 8/10/2016
1.0.0.11 3,913 6/29/2016
1.0.0.10 8,404 6/2/2016
1.0.0.9 8,014 11/24/2015
1.0.0.8 5,280 7/12/2015
1.0.0.7 7,732 3/17/2015