亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

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

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

GZipStream使用的一般流程如下:

打開一個(gè)現(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#程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論