Soenneker.Compression.SevenZip
11.0.1102
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Compression.SevenZip --version 11.0.1102
NuGet\Install-Package Soenneker.Compression.SevenZip -Version 11.0.1102
<PackageReference Include="Soenneker.Compression.SevenZip" Version="11.0.1102" />
<PackageVersion Include="Soenneker.Compression.SevenZip" Version="11.0.1102" />
<PackageReference Include="Soenneker.Compression.SevenZip" />
paket add Soenneker.Compression.SevenZip --version 11.0.1102
#r "nuget: Soenneker.Compression.SevenZip, 11.0.1102"
#:package Soenneker.Compression.SevenZip@11.0.1102
#addin nuget:?package=Soenneker.Compression.SevenZip&version=11.0.1102
#tool nuget:?package=Soenneker.Compression.SevenZip&version=11.0.1102
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- SharpCompress (>= 0.50.12)
- Soenneker.Asyncs.Semaphores (>= 11.0.42)
- Soenneker.Libraries.SevenZip (>= 11.0.575)
- Soenneker.Libraries.SevenZip.Linux (>= 11.0.566)
- Soenneker.Utils.Paths.Resources (>= 11.0.337)
- Soenneker.Utils.Process (>= 11.0.1633)
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 |
|---|---|---|
| 11.0.1118 | 0 | 12/3/2026 |
| 11.0.1117 | 0 | 12/3/2026 |
| 11.0.1116 | 53 | 12/3/2026 |
| 11.0.1115 | 50 | 12/3/2026 |
| 11.0.1114 | 58 | 12/3/2026 |
| 11.0.1113 | 61 | 12/3/2026 |
| 11.0.1112 | 54 | 12/2/2026 |
| 11.0.1111 | 64 | 12/2/2026 |
| 11.0.1108 | 68 | 12/2/2026 |
| 11.0.1107 | 99 | 12/2/2026 |
| 11.0.1106 | 85 | 12/2/2026 |
| 11.0.1105 | 86 | 12/2/2026 |
| 11.0.1104 | 94 | 12/2/2026 |
| 11.0.1103 | 94 | 12/1/2026 |
| 11.0.1102 | 76 | 12/1/2026 |
| 11.0.1101 | 95 | 12/1/2026 |
| 11.0.1100 | 85 | 12/1/2026 |
| 11.0.1099 | 73 | 12/1/2026 |
| 11.0.1098 | 95 | 12/1/2026 |
| 11.0.1097 | 96 | 12/1/2026 |
Updated Multiple NuGet packages