Ionic Zip Library v1.9.1.6
Reset Method (stream)
Reference ► Ionic.Zlib ► ParallelDeflateOutputStream ► Reset(Stream)
Resets the stream for use with another stream.
Declaration Syntax
Parameters
- stream (Stream)
- The new output stream for this era.
Remarks
Because the ParallelDeflateOutputStream is expensive to create, it
has been designed so that it can be recycled and re-used. You have
to call Close() on the stream first, then you can call Reset() on
it, to use it again on another stream.
Examples
CopyC#
ParallelDeflateOutputStream deflater = null; foreach (var inputFile in listOfFiles) { string outputFile = inputFile + ".compressed"; using (System.IO.Stream input = System.IO.File.OpenRead(inputFile)) { using (var outStream = System.IO.File.Create(outputFile)) { if (deflater == null) deflater = new ParallelDeflateOutputStream(outStream, CompressionLevel.Best, CompressionStrategy.Default, true); deflater.Reset(outStream); while ((n= input.Read(buffer, 0, buffer.Length)) != 0) { deflater.Write(buffer, 0, n); } } } }