All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
关于C#格式化日期时间_[Asp.Net教程]
开发一个适合Ajax+JSON+jQuery环境使用的多功能页码栏——jPagerBar-1.1.1_[AJAX教程]
单点登录在ASP.NET上的简单实现_[Asp.Net教程]
关于ASP.net服务器的入侵方法详解_[Asp.Net教程]
符合web标准的媒体播放器代码_[Html教程]
Zope的优点和Apache+PHP+MySQL的比较_php资料_编程技术
通过继承ConfigurationSection,在web.config中增加自定义配置_[Asp.Net教程]
网页设计必学:快速精通网页框架FRAME_[Html教程]
delphi滚动条组件(TScrollBar)使用方法
ASP.NET中Session的状态保持方式浅议_.net资料_编程技术
Reading number is top 10 pictures
The little girl with long hair3
The money of more than 100 countries and regions16
王艳写真温柔如水2
The household design, do not do bridal chamber a pity
清扫五脏垃圾,我有绝招
美丽的少女1
人美胸美腿更美3
Exquisite decoration is not paying too much1
The real super beauty3
[猫扑大杂烩]华东师范墙上看到的捐精告示 15毫升3600元
Download software ranking
C++教程第四版
尖东毒玫瑰A
Twenty piece of palm leaf
Tram sex maniac 2 (H) rar bag14
C语言教程TXT
The Bermuda triangle1
ASP.NET.2.0.XML.高级编程(第3版)
White deer villiage
小黑猫大战两米大花蛇
I for your crazy
delv published in(发表于) 2014/1/10 6:28:11 Edit(编辑)
ASP.NET技巧:用GZip压缩和解压_[Asp.Net教程]

ASP.NET技巧:用GZip压缩和解压_[Asp.Net教程]

ASP.NET技巧:用GZip压缩和解压_[Asp.Net教程]

.Net支持两种压缩格式:GZip和Deflate。我试了一下,压缩率和速度没区别。其中,GZip可以被WinRAR打开。


使用起来很简单,下面的程序将字符串压缩入文件:


using (DeflateStream gzip = new DeflateStream(fs, CompressionMode.Compress))
{
byte[] buf = Encoding.UTF8.GetBytes(this.txbSource.Text);
gzip.Write(buf, 0, buf.Length);
gzip.Flush();
}


解压只需要这样:


gzip = new GZipStream(new MemoryStream(buf), CompressionMode.Decompress);
using (StreamReader reader = new StreamReader(gzip))
{
this.txbTarget.Text = reader.ReadToEnd();
}


如果从文件解压,只需要把MemoryStream换成一个FileStream就行了。
当然,需要加:using System.IO.Compression;


来源:网络







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.