Soenneker.Compression.SevenZip 4.0.1029

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Compression.SevenZip --version 4.0.1029
                    
NuGet\Install-Package Soenneker.Compression.SevenZip -Version 4.0.1029
                    
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="Soenneker.Compression.SevenZip" Version="4.0.1029" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Compression.SevenZip" Version="4.0.1029" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Compression.SevenZip" />
                    
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 Soenneker.Compression.SevenZip --version 4.0.1029
                    
#r "nuget: Soenneker.Compression.SevenZip, 4.0.1029"
                    
#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 Soenneker.Compression.SevenZip@4.0.1029
                    
#: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=Soenneker.Compression.SevenZip&version=4.0.1029
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Compression.SevenZip&version=4.0.1029
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Compression.SevenZip

Extracts 7-Zip archives into temporary directories using either SharpCompress or a bundled native 7-Zip executable.

Installation

dotnet add package Soenneker.Compression.SevenZip

Registration

using Microsoft.Extensions.DependencyInjection;
using Soenneker.Compression.SevenZip.Registrars;

services.AddSevenZipCompressionUtilAsSingleton();

AddSevenZipCompressionUtilAsScoped() is also available.

Managed extraction

ExtractAdvanced uses SharpCompress and supports suffix filtering:

using Soenneker.Compression.SevenZip.Abstract;

string outputDirectory = await sevenZip.ExtractAdvanced(
    archivePath,
    specificFileFilter: ".json",
    cancellationToken: cancellationToken);

try
{
    foreach (string file in Directory.EnumerateFiles(
                 outputDirectory,
                 "*",
                 SearchOption.AllDirectories))
    {
        // Process each extracted JSON file.
    }
}
finally
{
    Directory.Delete(outputDirectory, recursive: true);
}

The filter is a case-insensitive EndsWith match, not a glob or regular expression. Directories are skipped. When nothing matches, the method returns an empty temporary directory.

Managed extraction is sequential by default. Set isParallel: true only for a trusted, tested workload where concurrent entry extraction is beneficial.

Native extraction

Extract runs the packaged native 7-Zip executable and extracts the complete archive:

string outputDirectory = await sevenZip.Extract(
    archivePath,
    cancellationToken);

The native path is available on Windows and Linux. It throws PlatformNotSupportedException on other operating systems. A non-zero 7-Zip exit code is surfaced as an exception.

Output ownership and failure behavior

  • Both methods create and return a new temporary directory. The caller owns that directory and must delete it after consuming the files.
  • On cancellation or extraction failure, the utility attempts to remove the incomplete directory before rethrowing the original error.
  • The source archive is opened read-only and is not deleted or modified.
  • Managed extraction rejects absolute/traversing paths, symbolic-link entries, and multiple entries that resolve to the same destination.
  • Managed entry failures are propagated; the method does not report a partially extracted directory as success.

Handling untrusted archives

Path validation does not make arbitrary archives resource-safe. Neither extraction method imposes limits on expanded byte count, compression ratio, entry count, nesting, or execution time beyond caller cancellation. Validate archive size and provenance, enforce application-level quotas and timeouts, and use an isolated process or container when accepting untrusted uploads.

Do not process extracted files as executable content merely because extraction succeeded.

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

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.1033 103 10/22/2026
4.0.1032 91 10/21/2026
4.0.1031 113 10/20/2026
4.0.1030 213 10/15/2026
4.0.1029 101 10/15/2026
4.0.1028 100 10/15/2026
4.0.1027 147 10/14/2026
4.0.1024 86 10/14/2026
4.0.1023 114 10/14/2026
4.0.1021 108 10/14/2026
4.0.1020 90 10/14/2026
4.0.1012 124 10/13/2026
4.0.1011 112 10/12/2026
4.0.1009 167 10/12/2026
4.0.1008 95 10/12/2026
4.0.1007 109 10/12/2026
4.0.1006 113 10/12/2026
4.0.1005 108 10/12/2026
4.0.1004 116 10/11/2026
4.0.1002 118 10/11/2026
Loading failed

Update dependency Soenneker.Utils.Paths.Resources to 4.0.296 (#1768)