• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    .net压缩功能实现方法
    复制代码 代码如下:

    public static class Compressor    {

                public static byte[] Compress(byte[] data)
                {
                    using (MemoryStream output = new MemoryStream())
                    {
                        using (GZipStream gzip = new GZipStream(output, CompressionMode.Compress, true))
                        {
                            gzip.Write(data, 0, data.Length);
                            gzip.Close();
                            return output.ToArray();
                        }
                    }
                }

                public static byte[] Decompress(byte[] data)
                {
                    using (MemoryStream input = new MemoryStream())
                    {
                        input.Write(data, 0, data.Length);
                        input.Position = 0;
                        using (GZipStream gzip = new GZipStream(input, CompressionMode.Decompress, true))
                        {
                            using (MemoryStream output = new MemoryStream())
                            {
                                byte[] buff = new byte[64];
                                int read = -1;
                                read = gzip.Read(buff, 0, buff.Length);
                                while (read > 0)
                                {
                                    output.Write(buff, 0, read);
                                    read = gzip.Read(buff, 0, buff.Length);
                                }
                                gzip.Close();
                                return output.ToArray();
                            }
                        }
                    }
                }
    您可能感兴趣的文章:
    • .NET 2.0 的压缩功能代码
    上一篇:asp.net导出Excel乱码的原因及解决方法
    下一篇:.net实现ping的实例代码
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯

    时间:9:00-21:00 (节假日不休)

    地址:江苏信息产业基地11号楼四层

    《增值电信业务经营许可证》 苏B2-20120278

    .net压缩功能实现方法 .net,压缩,功能,实现,方法,