Ionic Zip Library v1.9.1.6
BZip2OutputStream Constructor (output)
Reference ► Ionic.BZip2 ► BZip2OutputStream ► BZip2OutputStream(Stream)
Constructs a new BZip2OutputStream, that sends its
compressed output to the given output stream.


- output (Stream)
- The destination stream, to which compressed output will be sent.

This example reads a file, then compresses it with bzip2 file,
and writes the compressed data into a newly created file.
CopyC#

var fname = "logfile.log"; using (var fs = File.OpenRead(fname)) { var outFname = fname + ".bz2"; using (var output = File.Create(outFname)) { using (var compressor = new Ionic.BZip2.BZip2OutputStream(output)) { byte[] buffer = new byte[2048]; int n; while ((n = fs.Read(buffer, 0, buffer.Length)) > 0) { compressor.Write(buffer, 0, n); } } } }