SharpSevenZip 2.0.121

There is a newer version of this package available.
See the version list below for details.
dotnet add package SharpSevenZip --version 2.0.121
                    
NuGet\Install-Package SharpSevenZip -Version 2.0.121
                    
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="SharpSevenZip" Version="2.0.121" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SharpSevenZip" Version="2.0.121" />
                    
Directory.Packages.props
<PackageReference Include="SharpSevenZip" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SharpSevenZip --version 2.0.121
                    
#r "nuget: SharpSevenZip, 2.0.121"
                    
#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.
#:package SharpSevenZip@2.0.121
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SharpSevenZip&version=2.0.121
                    
Install as a Cake Addin
#tool nuget:?package=SharpSevenZip&version=2.0.121
                    
Install as a Cake Tool

SharpSevenZip

A managed C# wrapper around the native 7-Zip library. SharpSevenZip drives 7z.dll through its COM interface and adds an LZMA SDK implementation and self-extracting archive support on top.

Build status NuGet Version License

Resource Link
Source code github.com/JeremyAnsel/SharpSevenZip
Documentation jeremyansel.github.io/SharpSevenZip
NuGet SharpSevenZip
NuGet (strong-named) SharpSevenZip.StrongName
Build AppVeyor
License LGPL-3.0-or-later

Installation

dotnet add package SharpSevenZip

Target frameworks are net8.0, net48 and netstandard2.0. The package ships the x86 and x64 builds of 7z.dll and copies them into the corresponding subfolders of the output directory; set the MSBuild property ExcludeSevenZipAssemblies to true to suppress that.

Quick start

The library exposes three main types:

Type Purpose
SharpSevenZipExtractor Extracts archives, single entries or LZMA-compressed byte arrays
SharpSevenZipCompressor Creates and updates archives from files, directories or streams
SharpSevenZipSfx Builds self-extracting archives

LzmaEncodeStream and LzmaDecodeStream are fully managed Stream implementations for raw LZMA data and need no native library.

Extracting

using SharpSevenZip;

using var extractor = new SharpSevenZipExtractor(@"C:\archive.7z");

foreach (var entry in extractor.ArchiveFileData)
{
    Console.WriteLine($"{entry.FileName} ({entry.Size} bytes)");
}

extractor.ExtractArchive(@"C:\output");

The input format is detected from the archive signature, so every format in InArchiveFormat — 7z, zip, rar, cab, iso and many more — can be read. Extraction from SFX archives and other formats with embedded archives is supported as well.

Compressing

using SharpSevenZip;

var compressor = new SharpSevenZipCompressor
{
    ArchiveFormat = OutArchiveFormat.SevenZip,
    CompressionLevel = CompressionLevel.High
};

compressor.CompressDirectory(@"C:\input", @"C:\archive.7z");

Output is limited to the formats 7-Zip can write: SevenZip, Zip, Tar, GZip, BZip2 and XZ. GZip and BZip2 compress a single file at a time.

Native library

A native 7-Zip library is required at runtime. By default SharpSevenZip loads <directory of SharpSevenZip.dll>\x86\7z.dll or …\x64\7z.dll, matching the process architecture.

Another location can be configured in app.config or at runtime:

SharpSevenZipBase.SetLibraryPath(@"C:\Program Files\7-Zip\7z.dll");

7z.dll covers all archive operations. 7za.dll is a smaller variant restricted to 7z archives, and a custom build of the 7-Zip sources containing only the formats you need works too.

Features

  • All 7-Zip archive formats for reading, all writable formats for compression
  • Encryption, passwords and encrypted headers
  • Archive properties, archive updates and multi-volume archives
  • Streaming, multi-threading, configurable compression level and method
  • Self-extracting archives

Self-extracting archives

SharpSevenZipSfx uses the SFX module by Oleg Scherbakov, which is embedded in the assembly.

Alternative modules are available in SharpSevenZip/sfx. Combined with SfxSettings scenarios this can produce small installers; the available directives are listed under "configuration file parameters" of the SFX module.

Custom compression switches

SharpSevenZipCompressor.CustomParameters accepts the switches of the 7z.exe command line, for example to enable multi-threaded compression:

compressor.CustomParameters.Add("mt", "on");

The complete list of switches is documented in 7-zip.chm and SevenZipDoc.chm of a 7-Zip installation.

Strong naming

Two packages are published from the same sources:

Package Assembly identity
SharpSevenZip not strong-named
SharpSevenZip.StrongName strong-named, public key token 7b9e68449741c4c5

Use SharpSevenZip.StrongName when your own application or library is strong-named and therefore requires strong-named references. Both packages contain an assembly named SharpSevenZip, so a project can reference only one of them.

The key pair used for signing, SharpSevenZip/SharpSevenZip/SharpSevenZip.snk, is part of the repository. Anyone can build an assembly with that identity; strong naming provides an identity, not a security guarantee.

Benchmarks

Decompression compared against System.IO.Compression, SharpCompress and SevenZipSharp. Empty decompresses an empty archive, Sum1 a small payload; the stream variants read from a Stream instead of a file.

Scenario Library Mean (net48) Alloc (net48) Mean (net8.0) Alloc (net8.0)
Empty System.IO.Compression 1.077 ms 56 KB 2.990 ms 51.3 KB
Empty SharpCompress 2.902 ms 152 KB 7.448 ms 131.8 KB
Empty SevenZipSharp 7.412 ms 1440.1 KB 14.186 ms 1437.2 KB
Empty SharpSevenZip 2.238 ms 72 KB 7.723 ms 83.7 KB
Sum1 System.IO.Compression 5.875 ms 64 KB 8.799 ms 59.8 KB
Sum1 SharpCompress 5.156 ms 824.7 KB 9.976 ms 797.8 KB
Sum1 SharpCompress (stream) 8.936 ms 816.7 KB 12.757 ms 797.0 KB
Sum1 SevenZipSharp 24.214 ms 28333.2 KB 32.895 ms 28359.7 KB
Sum1 SharpSevenZip 9.725 ms 112 KB 19.595 ms 123.6 KB
Sum1 SharpSevenZip (stream) 34.122 ms 171.6 KB 18.431 ms 129.2 KB

The benchmark project is SharpSevenZipBenchmarks.

History

SharpSevenZip is a fork of Squid-Box.SevenZipSharp, which forked tomap's fork of the original CodePlex project by Markovtsev Vadim.

As required by the license, the notable changes since the CodePlex project, including those made in tomap's fork, are:

  • Target frameworks moved from .NET Framework 2.0 to .NET Standard 2.0, .NET Framework 4.8 and .NET 8.0.
  • Continuous integration added for both building and publishing.
  • Tests rewritten as NUnit 3 test cases.
  • General code cleanup, along with a number of improvements and bug fixes.

License

Licensed under the GNU Lesser General Public License v3.0 or later.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on SharpSevenZip:

Repository Stars
SteamAutoCracks/Steam-auto-crack
Steam Game Automatic Cracker
pebakery/pebakery
PEBakery is a script engine that specializes in customizing the Windows Preinstalled Environment (WinPE/WinRE).
Ameliorated-LLC/trusted-uninstaller-cli
Core functionality for AME Wizard
Version Downloads Last Updated
2.0.122 0 9/4/2026
2.0.121 52 9/3/2026
2.0.115 81 9/1/2026
2.0.111 121 8/31/2026
2.0.109 1,651 7/10/2026
2.0.107 454 7/6/2026
2.0.105 139 7/6/2026
2.0.100 314 6/26/2026
2.0.99 4,255 6/19/2026
2.0.96 3,614 6/18/2026
2.0.91 264 6/17/2026
2.0.88 150 6/17/2026
2.0.86 221 6/16/2026
2.0.85 109 6/16/2026
2.0.84 2,008 6/16/2026
2.0.77 304 6/10/2026
2.0.75 735 6/9/2026
2.0.70 262 6/8/2026
2.0.51 211 6/4/2026
1.0.0 32 9/3/2026
Loading failed