Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
GZipStream Constructor (Stream, CompressionLevel, Boolean)

GZipStream Constructor (Stream, CompressionLevel, Boolean)

.NET Framework 4.6 and 4.5

Initializes a new instance of the GZipStream class by using the specified stream and compression level, and optionally leaves the stream open.

Namespace:  System.IO.Compression
Assembly:  System (in System.dll)

new : 
        stream:Stream * 
        compressionLevel:CompressionLevel * 
        leaveOpen:bool -> GZipStream

Parameters

stream
Type: System.IO.Stream

The stream to write the compressed data to.

compressionLevel
Type: System.IO.Compression.CompressionLevel

One of the enumeration values that indicates whether to emphasize speed or compression efficiency when compressing the stream.

leaveOpen
Type: System.Boolean

true to leave the stream object open after disposing the GZipStream object; otherwise, false.

ExceptionCondition
ArgumentNullException

stream is a null reference (Nothing in Visual Basic).

ArgumentException

The stream does not support write operations such as compression. (The CanWrite property on the stream object is false.)

You use this constructor when you want to specify whether compression efficiency or speed is more important for an instance of the GZipStream class, and whether to leave the stream object open after disposing the GZipStream object.

This constructor overload uses the compression mode Compress. To set the compression mode to another value, use the GZipStream(Stream, CompressionMode) or GZipStream(Stream, CompressionMode, Boolean) overload.

The following example shows how to set the compression level when creating a GZipStream object and how to leave the stream open.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5

.NET for Windows Phone apps

Supported in: Windows Phone 8.1
Show:
© 2015 Microsoft