#region GZip
/// <summary>
/// 压缩
/// </summary>
/// <param name="inBytes"></param>
/// <returns></returns>
public static byte[] Compress(byte[] inBytes)
{
MemoryStream outStream = new MemoryStream();
using (MemoryStream intStream = new MemoryStream(inBytes))
{
using (GZipStream Compress =new GZipStream(outStream, CompressionMode.Compress))
{
intStream.CopyTo(Compress);
}
}
return outStream.ToArray();
}
/// <summary>
/// 解压
/// </summary>
/// <param name="inStream"></param>
/// <returns></returns>
public static byte[] Decompress(byte[] inStream)
{
byte[] result = null;
MemoryStream compressedStream = new MemoryStream(inStream);
using (MemoryStream outStream = new MemoryStream())
{
using (GZipStream Decompress = new GZipStream(compressedStream,CompressionMode.Decompress))
{
Decompress.CopyTo(outStream);
result = outStream.ToArray();
}
}
return result;
}
#endregion