C# Gzip解压

0x00.添加引用

using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

0x01.解压

    public static string GZipDecompress(Stream stream)
    {
        byte[] buffer = new byte[100];
        int length = 0;

        GZipStream gzs = new GZipStream(stream, CompressionMode.Decompress);
        MemoryStream ms = new MemoryStream();

        while ((length = gzs.Read(buffer, 0, buffer.Length)) != 0)
        {
            ms.Write(buffer, 0, length);
        }
        return Encoding.UTF8.GetString(ms.ToArray());
    }
}

 

0 0 投票数
文章评分
订阅评论
提醒
guest
0 评论
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x