Introduction

edit

Meziantou.Framework.Compression reads and writes the archive formats and the compressed streams that .NET does not support, with an API that looks like ZipArchive and ZipFile. It is written in C# only: it needs no native library and works with Native AOT.

Archives

FormatReadWriteType
7zYesYes (create and update)SevenZipArchive, SevenZipFile
RAR (RAR5, RAR 2.0 to 4.x)YesNoRarArchive, RarFile
zipYesYes (create and update)ZipArchive, ZipFile
tar, .tar.gz, .tar.bz2, .tar.xz, .tar.lzma, .tar.lz, .tar.zst, .tar.ZYesNo: use System.Formats.TarArchiveFile, ArchiveReader
  • 7z: LZMA, LZMA2, PPMd, BZip2, Deflate, Deflate64 and Copy, the BCJ, BCJ2 and Delta filters, AES-256 encryption of the content and of the names, solid blocks and multi-volume archives (.7z.001, .7z.002, ...).
  • RAR: the compression of RAR5 (including the larger dictionaries of RAR 7) and of RAR 2.9/4.x (LZ, PPMd and the standard filters), AES encryption of the content and of the headers, solid and multi-volume archives, self-extracting archives, symbolic and hard links.
  • zip: Stored, Deflate, Deflate64, BZip2, LZMA, PPMd, XZ, Zstandard, and the old Shrink, Reduce and Implode methods; ZipCrypto and WinZip AES encryption; Zip64; split archives (.z01, ..., .zip, and .zip.001, ...). Writing supports Stored, Deflate, BZip2, LZMA, PPMd, XZ and Zstandard (on .NET 11), ZipCrypto and WinZip AES encryption, and Zip64, to streams that do not need to be seekable: see Zip archives.

ArchiveFile opens an archive of any of these formats, detected from its content, and ArchiveReader reads one forward only, from a stream that does not need to be seekable: see Getting started.

Compressed streams

FormatCompressDecompressType
XZ (.xz)YesYesXzStream
LZMA alone (.lzma)YesYesLzmaStream
lzip (.lz)YesYesLZipStream
bzip2 (.bz2)YesYesBZip2Stream
Unix compress (.Z)NoYesUnixCompressStream

They work like GZipStream: see Compressed streams.