public static byte[] Zip(byte[] data)
{
MemoryStream mstream = new MemoryStream();
BZip2OutputStream zipOutStream = new BZip2OutputStream(mstream);
zipOutStream.Write(data, 0, data.Length);
zipOutStream.Finalize();
zipOutStream.Close();
byte[] result = mstream.ToArray();
mstream.Close();
return result;
}
public static byte[] Unzip(byte[] data)
{
MemoryStream mstream = new MemoryStream(data);
BZip2InputStream zipInputStream = new BZip2InputStream(mstream);
byte[] byteUncompressed = new byte[zipInputStream.Length];
zipInputStream.Read(byteUncompressed, 0, (int)byteUncompressed.Length);
zipInputStream.Close();
mstream.Close();
return byteUncompressed;
}