ZArchive.NET 0.1.0

dotnet add package ZArchive.NET --version 0.1.0
                    
NuGet\Install-Package ZArchive.NET -Version 0.1.0
                    
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="ZArchive.NET" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZArchive.NET" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="ZArchive.NET" />
                    
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 ZArchive.NET --version 0.1.0
                    
#r "nuget: ZArchive.NET, 0.1.0"
                    
#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 ZArchive.NET@0.1.0
                    
#: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=ZArchive.NET&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=ZArchive.NET&version=0.1.0
                    
Install as a Cake Tool

ZArchive.NET

Idiomatic .NET bindings for the ZArchive archive format (.zar / .wua).

ZArchive.NET wraps the official ZArchive C++ implementation behind a normal .NET API. Archives are zstd-compressed in 64 KiB blocks and support true random-access reads inside archived files — you can Seek and Read in a multi-gigabyte archived file without extracting it.

ZArchive.NET is an independent .NET binding for the ZArchive library and is not an official upstream project.

Why no C++ toolchain is required

The NuGet package ships a prebuilt native bridge library (zarchive_dotnet_native) for each supported platform under runtimes/<rid>/native/. The upstream ZArchive implementation and zstd are statically linked into that one library. Consumers only ever call the managed ZArchive.dll; no CMake, C++ compiler, or zstd installation is needed.

Installation

dotnet add package ZArchive.NET

Supported target framework: .NET 8.0+.

Supported platforms

Runtime identifier Status
win-x64 Built and tested
win-arm64, linux-x64, linux-arm64, osx-x64, osx-arm64 Planned (native builds pending CI runners)

A runtime identifier is only advertised once CI has executed the test suite on that platform.

Reading an archive

using ZArchive;

using ZArchiveReader archive = ZArchiveReader.Open("game.zar");

// List entries
foreach (ZArchiveEntry entry in archive.EnumerateEntries(recursive: true))
{
    Console.WriteLine($"{entry.EntryType}: {entry.FullName}");
}

// Random-access read of one archived file
using Stream input = archive.OpenRead("content/example.bin");
input.Seek(1024, SeekOrigin.Begin);
byte[] header = new byte[64];
input.ReadExactly(header);

Extracting safely

using ZArchiveReader archive = ZArchiveReader.Open("game.zar");
archive.ExtractToDirectory("extracted", new ZArchiveExtractionOptions
{
    Overwrite = false,
    Progress = progress,          // optional IProgress<ZArchiveExtractionProgress>
    CancellationToken = token,    // optional
});

Extraction validates every entry path: rooted paths, .. traversal segments and names invalid on the local filesystem are rejected with an IOException before any file is written.

Creating an archive

using ZArchive;

// Convenience: pack a whole directory
ZArchiveFile.CreateFromDirectory("ExtractedGame", "Game.zar");

// Manual control
using ZArchiveWriter writer = ZArchiveWriter.Create("assets.zar");
writer.CreateDirectory("textures");
using (Stream entry = writer.CreateEntry("textures/logo.bin"))
{
    entry.Write(data);
}
writer.Complete(); // the archive is only valid after Complete()

Archives are append-only: only one entry stream may be open at a time, and a writer disposed without Complete() deletes its partial output file.

Format and path notes

  • Archive paths use / as separator; \ is accepted and normalized, and a leading / is optional.
  • Lookups are case-insensitive for Latin letters (upstream behavior). Case is preserved in stored names.
  • Upstream stores names with Windows-1252 conventions; prefer names representable in Windows-1252 for maximum compatibility.
  • Archives cannot be modified after creation (upstream design).
  • Reads are synchronous native operations; the inherited async Stream methods wrap the synchronous implementation.

Native dependency information

  • Bridge library: zarchive_dotnet_native (C ABI, no C++ types exported).
  • Bundled upstream ZArchive and zstd versions: see THIRD-PARTY-NOTICES.md, or query ZArchiveInfo.UpstreamVersion at runtime.
  • On Windows the bridge statically links the MSVC runtime; no VC++ redistributable is needed.

Troubleshooting native loading

If loading fails, the thrown DllNotFoundException includes the OS, process architecture and runtime identifier. Common causes:

  • The platform/architecture has no native asset in the package (see the supported platforms table).
  • The app was published without runtime assets (e.g. some single-file configurations); ensure runtimes/<rid>/native/ content is preserved.

Building from source

With just installed, just build runs the whole sequence below (submodules, native build, staging, tests) for the current platform.

Manually: build the native bridge for the current platform, stage it, then build the managed side (<rid> is the runtime identifier, e.g. win-x64, linux-arm64, osx-arm64):

git clone --recurse-submodules https://github.com/Aspenini/zarchive-cs.git
cd zarchive-cs

cmake -S native -B native/build/<rid> -DCMAKE_BUILD_TYPE=Release
cmake --build native/build/<rid> --config Release
cmake --install native/build/<rid> --config Release --prefix artifacts/native/<rid>

dotnet test

Packing the cross-platform NuGet package

The package includes one native asset per RID: everything staged under artifacts/native/<rid>/ is packed into runtimes/<rid>/native/. To produce the full cross-platform package, run the three cmake commands above on each target platform (or cross-compile), collect the staged artifacts/native/<rid> directories onto one machine, then pack once:

dotnet pack src/ZArchive/ZArchive.csproj -c Release -o artifacts/packages

License

ZArchive.NET is licensed under MIT No Attribution. Bundled third-party components (ZArchive, its SHA-256 implementation, and zstd) are covered in THIRD-PARTY-NOTICES.md.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • 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
0.1.0 97 7/21/2026