Snappy for Windows

.NET tutorial

After downloading the library, your can use the Snappy namespace:

using Snappy;

You will gain access to low-level SnappyCodec API that provides block-level compression. Snappy.NET additionally contains SnappyStream that implements streaming API for streams of unbounded size.

SnappyCodec class provides you with a pair of simple compression/uncompression methods:

public static byte[] Compress(byte[] input);
public static byte[] Uncompress(byte[] input);

It cannot be simpler than that. If you would like to squeeze out the last bit of performance, there are corresponding two no-copy methods along with methods for estimating output buffer size. Explore the documentation via IntelliSense or by peeking into SnappyCodec class.

SnappyStream class is very similar to GZipStream class in .NET Framework. Note that SnappyStream creates output incompatible with SnappyCodec. While SnappyCodec is for compressing fixed-size blocks, SnappyStream is intended for unbounded streams. SnappyStream is however compatible with other implementations of Snappy framing specification. You can create Snappy-compressed file like this:

using (var file = File.OpenWrite(""))
using (var compressor = new SnappyStream(file, CompressionMode.Compress))
using (var writer = new StreamWriter(compressor))
    writer.WriteLine("Hello World!");

Decompression is similarly easy:

using (var file = File.OpenRead(""))
using (var decoder = new SnappyStream(file, CompressionMode.Decompress))
using (var reader = new StreamReader(decoder))

If you are on .NET 4.5, SnappyStream provides you with async variants of all I/O methods. If you would like to do advanced stream manipulation, you can use SnappyFrame class.

Project Snappy for Windows
NuGet Snappy (C++), Snappy.NET (.NET)
Download snappy-windows-
(C++, .NET, and command-line tools)
Source code snappy-visual-cpp, Snappy.NET, and snappy-command-line on Bitbucket
License BSD license
Credits Robert Važan, upstream Snappy