Keyoti RapidSpell Desktop .NET API Docs
ZlibStream Constructor (stream, mode, level, leaveOpen)
APIKeyoti.RapidSpell.CompressionZlibStreamZlibStream(Stream, CompressionMode, CompressionLevel, Boolean)
Keyoti RapidSpell Desktop .NET
Create a ZlibStream using the specified CompressionMode and the specified CompressionLevel, and explicitly specify whether the stream should be left open after Deflation or Inflation.
Declaration Syntax
C#C#Visual BasicVisual BasicVisual C++Visual C++F#F#
public ZlibStream(
	Stream stream,
	CompressionMode mode,
	CompressionLevel level,
	bool leaveOpen
)
public ZlibStream(
	Stream stream,
	CompressionMode mode,
	CompressionLevel level,
	bool leaveOpen
)
Public Sub New ( 
	stream As Stream,
	mode As CompressionMode,
	level As CompressionLevel,
	leaveOpen As Boolean
)
Public Sub New ( 
	stream As Stream,
	mode As CompressionMode,
	level As CompressionLevel,
	leaveOpen As Boolean
)
public:
ZlibStream(
	Stream^ stream, 
	CompressionMode mode, 
	CompressionLevel level, 
	bool leaveOpen
)
public:
ZlibStream(
	Stream^ stream, 
	CompressionMode mode, 
	CompressionLevel level, 
	bool leaveOpen
)
new : 
        stream : Stream * 
        mode : CompressionMode * 
        level : CompressionLevel * 
        leaveOpen : bool -> ZlibStream
new : 
        stream : Stream * 
        mode : CompressionMode * 
        level : CompressionLevel * 
        leaveOpen : bool -> ZlibStream
Parameters
stream (Stream)
The stream which will be read or written.
mode (CompressionMode)
Indicates whether the ZlibStream will compress or decompress.
level (CompressionLevel)
A tuning knob to trade speed for effectiveness. This parameter is effective only when mode is CompressionMode.Compress.
leaveOpen (Boolean)
true if the application would like the stream to remain open after inflation/deflation.
Remarks

This constructor allows the application to request that the captive stream remain open after the deflation or inflation occurs. By default, after Close() is called on the stream, the captive stream is also closed. In some cases this is not desired, for example if the stream is a MemoryStream that will be re-read after compression. Specify true for the leaveOpen parameter to leave the stream open.

When mode is CompressionMode.Decompress, the level parameter is ignored.

Examples
This example shows how to use a ZlibStream to compress the data from a file, and store the result into another file. The filestream remains open to allow additional data to be written to it.
 Copy imageCopy
using (var output = System.IO.File.Create(fileToCompress + ".zlib"))
{
    using (System.IO.Stream input = System.IO.File.OpenRead(fileToCompress))
    {
        using (Stream compressor = new ZlibStream(output, CompressionMode.Compress, CompressionLevel.BestCompression, true))
        {
            byte[] buffer = new byte[WORKING_BUFFER_SIZE];
            int n;
            while ((n= input.Read(buffer, 0, buffer.Length)) != 0)
            {
                compressor.Write(buffer, 0, n);
            }
        }
    }
    // can write additional data to the output stream here
}
Visual Basic Copy imageCopy
Using output As FileStream = File.Create(fileToCompress & ".zlib")
    Using input As Stream = File.OpenRead(fileToCompress)
        Using compressor As Stream = New ZlibStream(output, CompressionMode.Compress, CompressionLevel.BestCompression, True)
            Dim buffer As Byte() = New Byte(4096) {}
            Dim n As Integer = -1
            Do While (n <> 0)
                If (n > 0) Then
                    compressor.Write(buffer, 0, n)
                End If
                n = input.Read(buffer, 0, buffer.Length)
            Loop
        End Using
    End Using
    ' can write additional data to the output stream here.
End Using

Assembly: Keyoti.RapidSpell.NET4 (Module: Keyoti.RapidSpell.NET4.dll) Version: 6.2.21.412