伊图教程网[www.etoow.com]
http://www.etoow.com/html/2007-02/1170501916.html
18 /**//// <summary>
19 /// 压缩数据
20 /// </summary>
21 /// <param name="data">待压缩的字节数组</param>
22 /// <returns>压缩后的字节数组</returns>
23 public static byte[] CompressByte(byte[] data)
24 {
25 MemoryStream ms = new MemoryStream();
26 Stream s=new GZipOutputStream(ms);
27 s.Write( data, 0, data.Length );
28 s.Close();
29 return ms.ToArray();
30 }
31
32 /**//// <summary>
33 /// 解压数据
34 /// </summary>
35 /// <param name="data">待解压的字节数组</param>
36 /// <returns>解压出的字节数组</returns>
37 public static byte[] DeCompressByte(byte[] data)
38 {
39 byte[] writeData = new byte[2048];
40 MemoryStream ms= new MemoryStream( data );
41 Stream sm = new GZipInputStream(ms) as Stream;
42 MemoryStream outStream = new MemoryStream();
43 while (true)
44 {
45 int size = sm.Read(writeData,0, writeData.Length );
46 if (size >0)
47 {
小议优化ASP.NET应用性能之ViewState篇
'http://www.etoow.com/html/2007-02/1170501916.html