Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static byte[] Compress(byte[] bytes)
- {
- using (var ms = new MemoryStream())
- {
- using (var ds = new DeflateStream(ms, CompressionMode.Compress))
- {
- ds.Write(bytes, 0, bytes.Length);
- }
- return ms.ToArray();
- }
- }
- public static byte[] Decompress(byte[] bytes)
- {
- using (var ds = new DeflateStream(new MemoryStream(bytes), CompressionMode.Decompress))
- {
- using (var ms = new MemoryStream())
- {
- ds.CopyTo(ms);
- return ms.ToArray();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment