https://github.com/adamhathcock/sharpcompress
SharpCompress is a fully managed C# library to deal with many compression types and formats.
https://github.com/adamhathcock/sharpcompress
7zip bzip2 c-sharp compression dotnet-core gzip lzip lzma sharpcompress tar unrar xz zip
Last synced: about 1 month ago
JSON representation
SharpCompress is a fully managed C# library to deal with many compression types and formats.
- Host: GitHub
- URL: https://github.com/adamhathcock/sharpcompress
- Owner: adamhathcock
- License: mit
- Created: 2013-04-07T09:46:43.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2026-02-11T17:41:12.000Z (about 1 month ago)
- Last Synced: 2026-02-11T17:49:43.078Z (about 1 month ago)
- Topics: 7zip, bzip2, c-sharp, compression, dotnet-core, gzip, lzip, lzma, sharpcompress, tar, unrar, xz, zip
- Language: C#
- Homepage:
- Size: 25.6 MB
- Stars: 2,512
- Watchers: 86
- Forks: 506
- Open Issues: 286
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Agents: AGENTS.md
Awesome Lists containing this project
- awesome-csharp - SharpCompress - SharpCompress is a compression library for .NET/Mono/Silverlight/WP7 that can unrar, un7zip, unzip, untar unbzip2 and ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip are implemented (Compression)
- awesome-dotnet-cn - SharpCompress - SharpCompress 是一个用于 .NET、Mono、Silverlight、WP7 的压缩库,可以解压rar、7zip、zip、tar、bzip2 和 gzip,提供只读和随机文件访问API。支持对zip/tar/bzip2/gzip进行写入的实现。 (压缩)
- awesome-dotnet-core - sharpcompress - Fully managed C# library to deal with many compression types and formats. (Frameworks, Libraries and Tools / Compression)
- awesome-dotnet - SharpCompress - SharpCompress is a compression library for .NET/Mono/Silverlight/WP7 that can unrar, un7zip, unzip, untar unbzip2 and ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip are implemented (Compression)
- awesome-dotnet - SharpCompress - SharpCompress is a compression library for .NET/Mono/Silverlight/WP7 that can unrar, un7zip, unzip, untar unbzip2 and ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip are implemented (Compression)
- awesome-dot-dev - SharpCompress - SharpCompress is a compression library for .NET/Mono/Silverlight/WP7 that can unrar, un7zip, unzip, untar unbzip2 and ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip are implemented (Compression)
- awsome-dotnet - SharpCompress - SharpCompress is a compression library for .NET/Mono/Silverlight/WP7 that can unrar, un7zip, unzip, untar unbzip2 and ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip are implemented (Compression)
- fucking-awesome-dotnet-core - sharpcompress - Fully managed C# library to deal with many compression types and formats. (Frameworks, Libraries and Tools / Compression)
- awesome-dotnet - SharpCompress - SharpCompress is a compression library for .NET/Mono/Silverlight/WP7 that can unrar, un7zip, unzip, untar unbzip2 and ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip are implemented (Compression)
- awesome-dotnet-core - sharpcompress - Fully managed C# library to deal with many compression types and formats. (Frameworks, Libraries and Tools / Compression)
- awesome-dotnet-core - sharpcompress - 完全管理的C#库,用于处理许多压缩类型和格式。 (框架, 库和工具 / 压缩)
- fucking-awesome-dotnet - SharpCompress - SharpCompress is a compression library for .NET/Mono/Silverlight/WP7 that can unrar, un7zip, unzip, untar unbzip2 and ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip are implemented (Compression)
- system-architecture-awesome - SharpCompress - SharpCompress is a compression library for .NET/Mono/Silverlight/WP7 that can unrar, un7zip, unzip, untar unbzip2 and ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip are implemented (Compression)
- awesome-csharp - SharpCompress - A fully managed C# library to deal with many compression types and formats. (🗒️ Cheatsheets / 📦 Libraries)
README
# SharpCompress
SharpCompress is a compression library in pure C# for .NET Framework 4.8, .NET 8.0 and .NET 10.0 that can unrar, un7zip, unzip, untar unbzip2, ungzip, unlzip, unzstd, unarc and unarj with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip/lzip are implemented.
The major feature is support for non-seekable streams so large files can be processed on the fly (i.e. download stream).
**NEW:** All I/O operations now support async/await for improved performance and scalability. See the [USAGE.md](docs/USAGE.md#async-examples) for examples.
GitHub Actions Build -
[](https://github.com/adamhathcock/sharpcompress/actions/workflows/dotnetcore.yml)
[](https://dndocs.com/d/sharpcompress/api/index.html)
## Need Help?
Post Issues on Github!
Check the [Supported Formats](docs/FORMATS.md) and [Basic Usage.](docs/USAGE.md)
## Custom Compression Providers
If you need to swap out SharpCompress’s built-in codecs, the `Providers` property (and `WithProviders(...)` extensions) on `ReaderOptions` and `WriterOptions` lets you supply a `CompressionProviderRegistry`. The selected registry is used by Reader/Writer APIs, Archive APIs, and async extraction paths, so the same provider choice is applied consistently across open/read/write flows. The default registry is already wired up, so customization is only necessary when you want to plug in alternatives such as `SystemGZipCompressionProvider` or a third-party `CompressionProvider`. See [docs/USAGE.md#custom-compression-providers](docs/USAGE.md#custom-compression-providers) for guided examples.
## Recommended Formats
In general, I recommend GZip (Deflate)/BZip2 (BZip)/LZip (LZMA) as the simplicity of the formats lend to better long term archival as well as the streamability. Tar is often used in conjunction for multiple files in a single archive (e.g. `.tar.gz`)
Zip is okay, but it's a very hap-hazard format and the variation in headers and implementations makes it hard to get correct. Uses Deflate by default but supports a lot of compression methods.
RAR is not recommended as it's a proprietary format and the compression is closed source. Use Tar/LZip for LZMA
7Zip and XZ both are overly complicated. 7Zip does not support streamable formats. XZ has known holes explained here: (http://www.nongnu.org/lzip/xz_inadequate.html) Use Tar/LZip for LZMA compression instead.
ZStandard is an efficient format that works well for streaming with a flexible compression level to tweak the speed/performance trade off you are looking for.
## A Simple Request
Hi everyone. I hope you're using SharpCompress and finding it useful. Please give me feedback on what you'd like to see changed especially as far as usability goes. New feature suggestions are always welcome as well. I would also like to know what projects SharpCompress is being used in. I like seeing how it is used to give me ideas for future versions. Thanks!
Please do not email me directly to ask for help. If you think there is a real issue, please report it here.
## Want to contribute?
I'm always looking for help or ideas. Please submit code or email with ideas. Unfortunately, just letting me know you'd like to help is not enough because I really have no overall plan of what needs to be done. I'll definitely accept code submissions and add you as a member of the project!
## Notes
XZ implementation based on: https://github.com/sambott/XZ.NET by @sambott
XZ BCJ filters support contributed by Louis-Michel Bergeron, on behalf of aDolus Technology Inc. - 2022
7Zip implementation based on: https://code.google.com/p/managed-lzma/
Zstandard implementation from: https://github.com/oleg-st/ZstdSharp
LICENSE
Copyright (c) 2000 - 2011 The Legion Of The Bouncy Castle (http://www.bouncycastle.org)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.