Gzip压缩和解压
/// <summary> /// 将传入字符串以GZip算法压缩后,返回Base64编码字符 /// </summary> /// <param name="rawString">需要压缩的字符串</param> /// <returns>压缩后的Base64编码的字符串</returns> public string GZipCompressString(string rawString) { if (string.IsNullOrEmpty(rawString) || rawString.Length == 0) { return ""; } else { byte[] rawData = System.Text.Encoding.UTF8.GetBytes(rawString.ToString()); byte[] zippedData = Compress(rawData); return (string)(Convert.ToBase64String(zippedData)); } } /// <summary> /// GZip压缩 /// </summary> /// <param name="rawData"></param> /// <returns></returns> static byte[] Compress(byte[] rawData) {