如下资料是关于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();
}
网友评论