国产探花免费观看_亚洲丰满少妇自慰呻吟_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();
                        }
                    }
                }
            }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 枝江市| 瓦房店市| 屏东市| 延川县| 微山县| 颍上县| 新营市| 阿鲁科尔沁旗| 理塘县| 肥城市| 长白| 惠安县| 启东市| 闽侯县| 商南县| 瓮安县| 罗平县| 新龙县| 万山特区| 阿图什市| 绍兴市| 和林格尔县| 石城县| 南溪县| 吉林省| 定南县| 灵璧县| 海阳市| 澄江县| 靖西县| 兴义市| 思南县| 托里县| 松溪县| 张家界市| 博乐市| 会同县| 高雄市| 诸城市| 新乡市| 綦江县|