class DeflateStream

in global :: System . IO . Compression

Provides methods and properties for compressing and decompressing streams by using the Deflate algorithm.


public DeflateStream( Stream stream, CompressionLevel compressionLevel )

Initializes a new instance of the class by using the specified stream and compression level.

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

public DeflateStream( Stream stream, CompressionLevel compressionLevel, bool leaveOpen )

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

  • stream The stream to compress.
  • compressionLevel One of the enumeration values that indicates whether to emphasize speed or compression efficiency when compressing the stream.
  • leaveOpen to leave the stream object open after disposing the object; otherwise, .

public DeflateStream( Stream stream, CompressionMode mode )

Initializes a new instance of the class by using the specified stream and compression mode.

  • stream The stream to compress or decompress.
  • mode One of the enumeration values that indicates whether to compress or decompress the stream.

public DeflateStream( Stream stream, CompressionMode mode, bool leaveOpen )

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

  • stream The stream to compress or decompress.
  • mode One of the enumeration values that indicates whether to compress or decompress the stream.
  • leaveOpen to leave the stream open after disposing the object; otherwise, .

public Stream BaseStream { get; }

Gets a reference to the underlying stream.

  • Returns A stream object that represents the underlying stream.

public IAsyncResult BeginRead( byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState )

Begins an asynchronous read operation. (Consider using the method instead.)

  • buffer The byte array to read the data into.
  • offset The byte offset in at which to begin reading data from the stream.
  • count The maximum number of bytes to read.
  • asyncCallback An optional asynchronous callback, to be called when the read operation is complete.
  • asyncState A user-provided object that distinguishes this particular asynchronous read request from other requests.
  • Returns An object that represents the asynchronous read operation, which could still be pending.

public IAsyncResult BeginWrite( byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState )

Begins an asynchronous write operation. (Consider using the method instead.)

  • array The buffer to write data from.
  • offset The byte offset in to begin writing from.
  • count The maximum number of bytes to write.
  • asyncCallback An optional asynchronous callback, to be called when the write operation is complete.
  • asyncState A user-provided object that distinguishes this particular asynchronous write request from other requests.
  • Returns An object that represents the asynchronous write operation, which could still be pending.

public bool CanRead { get; }

Gets a value indicating whether the stream supports reading while decompressing a file.

  • Returns if the value is , and the underlying stream is opened and supports reading; otherwise, .

public bool CanSeek { get; }

Gets a value indicating whether the stream supports seeking.

  • Returns in all cases.

public bool CanWrite { get; }

Gets a value indicating whether the stream supports writing.

  • Returns if the value is , and the underlying stream supports writing and is not closed; otherwise, .

public int EndRead( IAsyncResult asyncResult )

Waits for the pending asynchronous read to complete. (Consider using the method instead.)

  • asyncResult The reference to the pending asynchronous request to finish.
  • Returns The number of bytes read from the stream, between 0 (zero) and the number of bytes you requested. returns 0 only at the end of the stream; otherwise, it blocks until at least one byte is available.

public void EndWrite( IAsyncResult asyncResult )

Ends an asynchronous write operation. (Consider using the method instead.)

  • asyncResult A reference to the outstanding asynchronous I/O request.

public long Length { get; }

This property is not supported and always throws a .

  • Returns A long value.

public long Position { get; set; }

This property is not supported and always throws a .

  • Returns A long value.

public int Read( byte[] buffer, int offset, int count )

Reads a number of decompressed bytes into the specified byte array.

  • array The array to store decompressed bytes.
  • offset The byte offset in at which the read bytes will be placed.
  • count The maximum number of decompressed bytes to read.
  • Returns The number of bytes that were read into the byte array.

public Task<int> ReadAsync( byte[] buffer, int offset, int count, CancellationToken cancellationToken )

Asynchronously reads a sequence of bytes from the current Deflate stream, writes them to a byte array, advances the position within the Deflate stream by the number of bytes read, and monitors cancellation requests.

  • array The buffer to write the data into.
  • offset The byte offset in at which to begin writing data from the Deflate stream.
  • count The maximum number of bytes to read.
  • cancellationToken The token to monitor for cancellation requests. The default value is .
  • Returns A task that represents the asynchronous read operation, which wraps the total number of bytes read into the . The result value can be less than the number of bytes requested if the number of bytes currently available is less than the requested number, or it can be 0 (zero) if the end of the Deflate stream has been reached.

public long Seek( long offset, SeekOrigin origin )

This operation is not supported and always throws a .

  • offset The location in the stream.
  • origin One of the values.
  • Returns A long value.

public void SetLength( long value )

This operation is not supported and always throws a .

  • value The length of the stream.

public void Write( byte[] buffer, int offset, int count )

Writes compressed bytes to the underlying stream from the specified byte array.

  • array The buffer that contains the data to compress.
  • offset The byte offset in from which the bytes will be read.
  • count The maximum number of bytes to write.

public Task WriteAsync( byte[] buffer, int offset, int count, CancellationToken cancellationToken )

Asynchronously writes compressed bytes to the underlying Deflate stream from the specified byte array.

  • array The buffer that contains the data to compress.
  • offset The zero-based byte offset in from which to begin copying bytes to the Deflate stream.
  • count The maximum number of bytes to write.
  • cancellationToken The token to monitor for cancellation requests. The default value is .
  • Returns A task that represents the asynchronous write operation.

public Type GetType( )

😔 No documentation found.

public object InitializeLifetimeService( )

😔 No documentation found.

public Task<int> ReadAsync( byte[] buffer, int offset, int count )

😔 No documentation found.

public bool Equals( object obj )

😔 No documentation found.

public object GetLifetimeService( )

😔 No documentation found.

public int ReadAtLeast( Span<byte> buffer, int minimumBytes, bool throwOnEndOfStream = True )

😔 No documentation found.

public void ReadExactly( byte[] buffer, int offset, int count )

😔 No documentation found.

public int GetHashCode( )

😔 No documentation found.

public void ReadExactly( Span<byte> buffer )

😔 No documentation found.

public Task WriteAsync( byte[] buffer, int offset, int count )

😔 No documentation found.

public ValueTask<int> ReadAtLeastAsync( Memory<byte> buffer, int minimumBytes, bool throwOnEndOfStream = True, CancellationToken cancellationToken = null )

😔 No documentation found.

public ValueTask ReadExactlyAsync( byte[] buffer, int offset, int count, CancellationToken cancellationToken = null )

😔 No documentation found.

public ValueTask ReadExactlyAsync( Memory<byte> buffer, CancellationToken cancellationToken = null )

😔 No documentation found.

public string ToString( )

😔 No documentation found.

public Task FlushAsync( )

😔 No documentation found.

public DeflateStream( Stream stream, ZLibCompressionOptions compressionOptions, bool leaveOpen = False )

😔 No documentation found.

public bool CanTimeout { get; }

😔 No documentation found.

public void Flush( )

😔 No documentation found.

public Task FlushAsync( CancellationToken cancellationToken )

😔 No documentation found.

public int ReadByte( )

😔 No documentation found.

public int Read( Span<byte> buffer )

😔 No documentation found.

public ValueTask<int> ReadAsync( Memory<byte> buffer, CancellationToken cancellationToken = null )

😔 No documentation found.

public void WriteByte( byte value )

😔 No documentation found.

public void Write( ReadOnlySpan<byte> buffer )

😔 No documentation found.

public ValueTask DisposeAsync( )

😔 No documentation found.

public ValueTask WriteAsync( ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken )

😔 No documentation found.

public void CopyTo( Stream destination, int bufferSize )

😔 No documentation found.

public Task CopyToAsync( Stream destination, int bufferSize, CancellationToken cancellationToken )

😔 No documentation found.

public int ReadTimeout { get; set; }

😔 No documentation found.

public int WriteTimeout { get; set; }

😔 No documentation found.

public void CopyTo( Stream destination )

😔 No documentation found.

public Task CopyToAsync( Stream destination )

😔 No documentation found.

public Task CopyToAsync( Stream destination, int bufferSize )

😔 No documentation found.

public Task CopyToAsync( Stream destination, CancellationToken cancellationToken )

😔 No documentation found.

public void Close( )

😔 No documentation found.

public void Dispose( )

😔 No documentation found.