国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

.net壓縮功能實現方法

2024-07-10 13:27:03
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:


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();
                        }
                    }
                }
            }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南平市| 汽车| 那坡县| 六盘水市| 丰都县| 宝应县| 民和| 承德市| 宁明县| 天长市| 平舆县| 开封市| 清丰县| 哈巴河县| 鄂托克前旗| 烟台市| 苏尼特左旗| 微山县| 衡山县| 南投县| 吉林省| 洛扎县| 胶州市| 塔城市| 桦甸市| 秀山| 杭锦后旗| 台江县| 马山县| 鹤山市| 上思县| 通州市| 大余县| 长寿区| 沂源县| 师宗县| 虹口区| 涟源市| 曲松县| 京山县| 淮滨县|