Skip to content

Latest commit

 

History

History
12 lines (7 loc) · 1.15 KB

File metadata and controls

12 lines (7 loc) · 1.15 KB

By default, xref:System.IO.Compression.DeflateStream owns the underlying stream, so closing the stream also closes the underlying stream. Note that the state of the underlying stream can affect the usability of the stream. Also, no explicit checks are performed, so no additional exceptions are thrown when the new instance is created.

If an instance of the xref:System.IO.Compression.DeflateStream class is created with the mode parameter equal to Compress, header information is inserted immediately. If no further action occurs, the stream appears as a valid, empty, compressed file.

By default, the compression level is set to xref:System.IO.Compression.CompressionLevel.Optimal when the compression mode is xref:System.IO.Compression.CompressionMode.Compress.

Examples

The following example shows how to use the xref:System.IO.Compression.DeflateStream class to compress and decompress a file.

:::code language="csharp" source="/snippets/csharp/System.IO.Compression/Deflate/FileCompressionModeExample.cs" id="Snippet1"::: :::code language="vb" source="/snippets/visualbasic/System.IO.Compression/Deflate/FileCompressionModeExample.vb" id="Snippet1":::