ZLIB Binary Compressor & Decompressor written in C-Sharp (C#)
The best easy to use compressor & decompressor for zlib is ready for you to use in you projects free and open source!
Options the library has to offer:
- Compress file content, string, and buffers (Byte array).
- Decompress any compressed file
Open a Visual Studio C# project, Then follow the steps below.
- Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution
- Now the NuGet Package Manager will be opened. Click on Browse
- Search for the keyword "zlib.net" and install it
- Download the DLL file from the Releases page
- In Visual Studio - Project -> Add Project Reference
- Then click on Browse and choose the DLL file
- Click OK
using System;
using System.Text;
using NoamRaz.ZLIB;
class Example
{
public static void Main()
{
Encoding encoding = UTF8Encoding.UTF8;
// Compress string
ZLIB.CompressString("Hello ZLIB World!", "MyFolder/MyCompressedFile.zlib", encoding);
// Compress file
ZLIB.CompressFile("MyFolder/FileToCompress.txt", "MyFolder/MyCompressedFile.zlib", encoding);
// Compress buffer (byte array)
byte[] buffer = UTF8Encoding.UTF8.GetBytes("Hello ZLIB World!");
ZLIB.CompressData(buffer, out byte[] result);
Console.WriteLine("Compressed Data is: ", result);
// Decompress compressed file
ZLIB.Decompress("MyFolder/MyCompressedFile.zlib", "MyFolder/MyDecompressedFile.txt", encoding);
// Decompress buffer (byte array)
byte[] decompBuffer = encoding.GetBytes("Hello ZLIB World!");
ZLIB.DecompressData(decompBuffer, out byte[] decompResult);
Console.WriteLine("Compressed Data is: ", encoding.GetString(decompResult));
}
}
Good Luck!