CommonNetFuncs.Compression
1.0.47
See the version list below for details.
dotnet add package CommonNetFuncs.Compression --version 1.0.47
NuGet\Install-Package CommonNetFuncs.Compression -Version 1.0.47
<PackageReference Include="CommonNetFuncs.Compression" Version="1.0.47" />
paket add CommonNetFuncs.Compression --version 1.0.47
#r "nuget: CommonNetFuncs.Compression, 1.0.47"
// Install CommonNetFuncs.Compression as a Cake Addin #addin nuget:?package=CommonNetFuncs.Compression&version=1.0.47 // Install CommonNetFuncs.Compression as a Cake Tool #tool nuget:?package=CommonNetFuncs.Compression&version=1.0.47
CommonNetFuncs.Compression
This project contains helper methods for compressing files into a zip file as well as compress and decompress streams.
Contents
Files
Used for compressing file data into a ZipArchive class.
<details> <summary><h3>Usage Examples</h3></summary>
Add file to zip folder and write it to disk.
using static CommonNetFuncs.Compression.Files;
using static CommonNetFuncs.Excel.Npoi.Export;
public async Task CreatePeopleZipFile()
{
List<Person> people = [];
//Some code populating people list here
await using MemoryStream zipStream = new();
//Converts list to excel file in a MemoryStream (see Excel.Npoi)
await using MemoryStream peopleExcelStream = await people.GenericExcelExport() ?? new();
await (peopleExcelStream, "People.xlsx").ZipFile(zipStream, CompressionLevel.SmallestSize);
peopleExcelStream.Dispose();
zipStream.Position = 0;
//Write the zip file to disk
await using FileStream fs = new("People.zip", FileMode.Create, FileAccess.Write);
await zipStream.CopyToAsync(fs);
fs.Flush();
}
Add multiple files to a ZipArchive object and write it to disk.
public async Task CreatePeopleAndAddressesZipFile()
{
List<Person> people = [];
List<Address> addresses = [];
//Some code populating people and addresses lists here
await using MemoryStream zipStream = new();
using ZipArchive archive = new(zipStream, ZipArchiveMode.Create, true);
//Convert lists to excel file in a MemoryStream (see Excel.Npoi) then add them to a ZipArchive
await using MemoryStream peopleExcelStream = await people.GenericExcelExport() ?? new();
await peopleExcelStream.AddFileToZip(archive, "People.xlsx", CompressionLevel.SmallestSize);
peopleExcelStream.Dispose();
await using MemoryStream addressesExcelStream = await addresses.GenericExcelExport() ?? new();
await addressesExcelStream.AddFileToZip(archive, "Addresses.xlsx", CompressionLevel.SmallestSize);
addressesExcelStream.Dispose();
archive.Dispose();
await using FileStream fs = new("PeopleAndAddresses.zip", FileMode.Create, FileAccess.Write);
await zipStream.CopyToAsync(fs);
fs.Flush();
}
</details>
Streams
Used for compressing and decompressing streams of data. Currently supported compression algorithms:
- Brotli
- GZip
- Deflate
- ZLib
<details> <summary><h3>Usage Examples</h3></summary>
Compress and then decompress a stream. CommonNetFuncs.Web.Requests has a more practical implementation decompressing compressed API responses.
public async Task CompressAndDecompressFile()
{
//Create stream
await using FileStream fileStream = new("TestFile.txt", FileMode.Open, FileAccess.Read);
//Compress the stream
await using MemoryStream compressedStream = new();
await fileStream.DecompressStream(compressedStream, ECompressionType.Gzip);
//Decompress the stream
await using MemoryStream decompressedStream = new();
await compressedStream.DecompressStream(decompressedStream, ECompressionType.Gzip);
}
</details>
Product | Versions 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. |
-
net8.0
- CommonNetFuncs.Core (>= 1.0.47)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on CommonNetFuncs.Compression:
Package | Downloads |
---|---|
CommonNetFuncs.Web.Requests
Helper methods that deal with creating, sending, and handling the responses from REST API calls |
|
CommonNetFuncs.Email
Helper methods that deal with sending email, including an SMTP email sending service and an HTML email builder helper. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.5 | 55 | 11/26/2024 |
2.0.2 | 91 | 11/18/2024 |
2.0.1 | 84 | 11/15/2024 |
2.0.0 | 83 | 11/14/2024 |
1.0.47 | 99 | 11/14/2024 |
1.0.42 | 120 | 11/12/2024 |
1.0.40 | 110 | 11/12/2024 |
1.0.37 | 101 | 11/4/2024 |
1.0.31 | 106 | 10/31/2024 |
1.0.28 | 105 | 10/25/2024 |
1.0.26 | 157 | 10/18/2024 |
1.0.25 | 85 | 10/17/2024 |
1.0.24 | 86 | 10/17/2024 |
1.0.18 | 127 | 10/11/2024 |
1.0.17 | 149 | 9/27/2024 |
1.0.16 | 124 | 9/27/2024 |
1.0.14 | 108 | 9/23/2024 |
1.0.13 | 120 | 9/18/2024 |
1.0.12 | 109 | 9/18/2024 |
1.0.11 | 105 | 9/18/2024 |
1.0.10 | 134 | 9/11/2024 |
1.0.9 | 123 | 9/11/2024 |
1.0.8 | 146 | 9/11/2024 |
1.0.7 | 128 | 9/11/2024 |
1.0.1 | 149 | 9/4/2024 |
1.0.0 | 122 | 9/2/2024 |