C#通过GZipStream压缩数据文件的代码

2019-05-16  本文已影响0人  联联小子

如下资料是关于C#通过GZipStream压缩数据文件的代码,应该对各朋友有所帮助。

String sourcefilename = FILETOBECOMPRESSED;

Filestream sourcefile = File.OpenRead(sourcefilename);

Filestream destinationfile = File.Create(outputfilename);

GZipStream compressionstream = new GZipStream(destinationfile, CompressionMode.Compress);

int sourcebyte = sourcefile.ReadByte();

while(sourcebyte != -1)

{

compressionstream.WriteByte((byte)sourcebyte);

sourcebyte = sourcefile.ReadByte();

}

上一篇 下一篇

猜你喜欢

热点阅读