Soenneker.Compression.Zip
4.0.4
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Compression.Zip --version 4.0.4
NuGet\Install-Package Soenneker.Compression.Zip -Version 4.0.4
<PackageReference Include="Soenneker.Compression.Zip" Version="4.0.4" />
<PackageVersion Include="Soenneker.Compression.Zip" Version="4.0.4" />
<PackageReference Include="Soenneker.Compression.Zip" />
paket add Soenneker.Compression.Zip --version 4.0.4
#r "nuget: Soenneker.Compression.Zip, 4.0.4"
#:package Soenneker.Compression.Zip@4.0.4
#addin nuget:?package=Soenneker.Compression.Zip&version=4.0.4
#tool nuget:?package=Soenneker.Compression.Zip&version=4.0.4
Soenneker.Compression.Zip
High-performance, asynchronous ZIP compression and secure extraction for .NET.
Features
- Streams file contents asynchronously with configurable buffers
- Atomically replaces completed archive files, preserving the previous archive on failure
- Writes extracted files to temporary files before moving them into place
- Rejects ZIP-slip traversal, links, duplicate destinations, and file/directory collisions
- Supports optional entry-count, expanded-size, and compression-ratio limits for untrusted archives
- Preserves file and directory timestamps
- Supports paths and caller-owned streams
- Uses only the ZIP implementation built into .NET
Installation
dotnet add package Soenneker.Compression.Zip
Quick start
using Soenneker.Compression.Zip;
var zip = new ZipUtil();
await zip.Compress("./input", "./output/archive.zip", cancellationToken: cancellationToken);
await zip.Extract("./output/archive.zip", "./restored", cancellationToken: cancellationToken);
Extraction does not overwrite existing files by default. Opt in when replacement is intended:
using Soenneker.Compression.Zip.Options;
await zip.Extract(
"./archive.zip",
"./destination",
new ZipExtractionOptions { OverwriteFiles = true },
cancellationToken);
Dependency injection
using Soenneker.Compression.Zip.Registrars;
services.AddZipUtilAsSingleton();
Then inject IZipUtil:
using Soenneker.Compression.Zip.Abstract;
public sealed class ArchiveService(IZipUtil zip)
{
public ValueTask Backup(string source, string archive, CancellationToken cancellationToken = default) =>
zip.Compress(source, archive, cancellationToken: cancellationToken);
}
Compression options
using System.IO.Compression;
using Soenneker.Compression.Zip.Options;
var options = new ZipCompressionOptions
{
CompressionLevel = CompressionLevel.Fastest,
IncludeBaseDirectory = true,
Overwrite = true,
PreserveTimestamps = true,
BufferSize = 128 * 1024
};
await zip.Compress("./input", "./archive.zip", options, cancellationToken);
File-system reparse points are intentionally skipped during compression.
Extracting untrusted archives
Path and link validation is always enabled. For externally supplied archives, set limits appropriate for your workload to reduce ZIP-bomb risk:
var options = new ZipExtractionOptions
{
MaximumEntryCount = 10_000,
MaximumEntrySize = 256L * 1024 * 1024,
MaximumTotalUncompressedSize = 2L * 1024 * 1024 * 1024,
MaximumCompressionRatio = 200
};
await zip.Extract(uploadStream, "./destination", options, cancellationToken);
Caller-owned streams remain open. Archive streams used for extraction must be readable and seekable.
| Product | Versions 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. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.11)
- Soenneker.Utils.Directory (>= 4.0.923)
- Soenneker.Utils.ExecutionContexts (>= 4.0.39)
- Soenneker.Utils.File (>= 4.0.2254)
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.24 | 61 | 9/16/2026 |
| 4.0.22 | 71 | 9/16/2026 |
| 4.0.21 | 78 | 9/16/2026 |
| 4.0.20 | 76 | 9/15/2026 |
| 4.0.19 | 86 | 9/13/2026 |
| 4.0.18 | 88 | 9/13/2026 |
| 4.0.17 | 82 | 9/13/2026 |
| 4.0.16 | 88 | 9/12/2026 |
| 4.0.15 | 86 | 9/12/2026 |
| 4.0.14 | 101 | 9/9/2026 |
| 4.0.13 | 100 | 9/9/2026 |
| 4.0.12 | 95 | 9/8/2026 |
| 4.0.11 | 98 | 9/8/2026 |
| 4.0.10 | 96 | 9/8/2026 |
| 4.0.9 | 96 | 9/8/2026 |
| 4.0.8 | 101 | 9/7/2026 |
| 4.0.7 | 104 | 9/7/2026 |
| 4.0.6 | 89 | 9/7/2026 |
| 4.0.5 | 98 | 9/7/2026 |
| 4.0.4 | 95 | 9/6/2026 |
Update dependency Soenneker.Utils.File to 4.0.2254 (#2)
Automatically merged