Chessar.LongPaths 1.0.0-rc003

This is a prerelease version of Chessar.LongPaths.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Chessar.LongPaths --version 1.0.0-rc003
NuGet\Install-Package Chessar.LongPaths -Version 1.0.0-rc003
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="Chessar.LongPaths" Version="1.0.0-rc003" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Chessar.LongPaths --version 1.0.0-rc003
#r "nuget: Chessar.LongPaths, 1.0.0-rc003"
#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 Chessar.LongPaths as a Cake Addin
#addin nuget:?package=Chessar.LongPaths&version=1.0.0-rc003&prerelease

// Install Chessar.LongPaths as a Cake Tool
#tool nuget:?package=Chessar.LongPaths&version=1.0.0-rc003&prerelease

Chessar.LongPaths

Chessar.LongPaths is a .NET library that allows you to enable long path support for the main System.IO classes:

FileStream, File, FileInfo, Directory, DirectoryInfo, ... (and others, for example Image.FromFile).

The library is based on replacing the internal NormalizePath and GetFullPathInternal functions from the static Path class. The replacement is done using JMP hooks (thanks to @wledfor2), in which the long path prefix \\?\ or \\?\UNC\ is added. Adding a prefix is done by calling the internal function Path.AddLongPathPrefix. Note also that the addition of such prefixes depends on the UseLegacyPathHandling and BlockLongPaths settings, which must necessarily be false (in the AppContextSwitchOverrides element).

In this case, your code does not need to directly add such prefixes to the paths.

Supported Platforms:

How to use

  1. Add the Chessar.LongPaths NuGet package to the project.
  2. In the file app.config, in the section runtime, add:
<configuration>
...
<runtime>
  <AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false;Switch.System.IO.BlockLongPaths=false" />
</runtime>
...
  1. In the code (when you start the application or at the beginning of Main) add code:
...
using static Chessar.Hooks;
...

    PatchLongPaths();

  1. At the end of the application:
    RemoveLongPathsPatch();

Notes

For the following list of ctors/methods, you must directly specify the prefix of long paths (because they are not supported by this library):

for example:

...
using static Chessar.Hooks;
...
    var ds = new DirectorySecurity(path.AddLongPathPrefix(), acs);

Note that Directory.SetCurrentDirectory does not work for long paths, even if a prefix is added.

License

MIT - See LICENSE

Product Compatible and additional computed target framework versions.
.NET Framework net462 is compatible.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.8 1,546 10/25/2018
1.1.7 760 10/2/2018
1.1.7-rc003 572 10/2/2018
1.1.6 735 9/24/2018
1.1.5 716 9/23/2018
1.1.4 752 9/21/2018
1.1.3 739 9/20/2018
1.1.2 746 9/16/2018
1.1.1 760 9/12/2018
1.1.0 764 9/10/2018
1.0.9 813 9/4/2018
1.0.8 776 8/26/2018
1.0.7 820 7/30/2018
1.0.6 778 7/25/2018
1.0.5 800 7/19/2018
1.0.4 879 7/18/2018
1.0.3 893 7/18/2018
1.0.2 882 7/18/2018
1.0.1 918 7/12/2018
1.0.0 889 7/12/2018
1.0.0-rc005 660 7/5/2018
1.0.0-rc004 729 6/20/2018
1.0.0-rc003 721 6/18/2018

First pre-release