美文网首页
C#通过GZipStream压缩数据文件的代码

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

作者: 联联小子 | 来源:发表于2019-05-16 10:43 被阅读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();

}

相关文章

网友评论

      本文标题:C#通过GZipStream压缩数据文件的代码

      本文链接:https://www.haomeiwen.com/subject/wjpbaqtx.html