Created
December 31, 2016 18:06
-
-
Save hclewk/380770e0acd4cfdb397cbcd9e8abaf3e to your computer and use it in GitHub Desktop.
GZip a string in c#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MemoryStream mem = new MemoryStream(); | |
using (GZipStream gz = new GZipStream(mem, CompressionLevel.Optimal, true)) | |
{ | |
var b = Encoding.UTF8.GetBytes(json); | |
gz.Write(b, 0, b.Length); | |
gz.Flush(); | |
} | |
var data = mem.ToArray(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment