欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#使用GZipStream解壓縮數(shù)據(jù)文件的方法

 更新時間:2015年04月13日 09:03:52   作者:令狐不聰  
這篇文章主要介紹了C#使用GZipStream解壓縮數(shù)據(jù)文件的方法,實例分析了C#中GZipStream方法的原理與使用技巧,需要的朋友可以參考下

本文實例講述了C#使用GZipStream解壓縮數(shù)據(jù)文件的方法。分享給大家供大家參考。具體分析如下:

GZipStream用于從一個流讀取數(shù)據(jù)寫入到另一個流,GZipStream不能寫入到其它的資源,比如文件或者內(nèi)存,只能從流到流。

GZipStream使用的一般流程如下:

打開一個現(xiàn)有的文件 
打開/創(chuàng)建輸出文件 
創(chuàng)建GZipStream對象 
逐字節(jié)讀源文件,并把它傳遞到GZipStream 
使用GZipStream寫入到輸出文件流

String sourcefilename = FILETOBEUNCOMPRESSED;
Filestream sourcefile = File.OpenRead(sourcefilename);
Filestream destinationfile = File.Create(outputfilename);
GZipStream compressionstream = new GZipStream(sourcefile, CompressionMode.Decompress);
int sourcebyte = compressionstream.ReadByte();
while(sourcebyte != -1)
{
  destinationfile.WriteByte((byte)sourcebyte);
  sourcebyte = compressionstream.ReadByte();
}

希望本文所述對大家的C#程序設計有所幫助。

相關文章

最新評論