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

首頁 > 編程 > .NET > 正文

.net實現壓縮功能的方法

2024-07-10 12:54:10
字體:
來源:轉載
供稿:網友

?關于.net壓縮功能有很多的小伙伴們不知道該如何去實現,那么現在本文就將為大家介紹.net實現壓縮功能的方法,其實.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實現壓縮功能的方法后你是不是明白了呢?想了解更多的ASP.NET知識就請關注我們錯新技術頻道吧!?

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东源县| 古蔺县| 都安| 建瓯市| 淄博市| 聂拉木县| 措美县| 崇义县| 玉林市| 巴中市| 怀来县| 青海省| 普格县| 崇州市| 永修县| 深圳市| 安远县| 福泉市| 化德县| 铜山县| 东城区| 内黄县| 姚安县| 图木舒克市| 海口市| 汤阴县| 宁南县| 南皮县| 富阳市| 兰州市| 洛浦县| 资兴市| 德保县| 运城市| 楚雄市| 榆社县| 石阡县| 什邡市| 尤溪县| 新巴尔虎右旗| 罗江县|