Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​IO.​Compression.​DeflateStream

Assembly: System.IO.Compression

Inheritance: object → MarshalByRefObjectStream → DeflateStream

Implemented Interfaces

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

Properties

public Stream
BaseStream
Gets a reference to the underlying stream.
public bool
CanRead
Gets a value indicating whether the stream supports reading while decompressing a file.
public bool
CanSeek
Gets a value indicating whether the stream supports seeking.
public bool
CanWrite
Gets a value indicating whether the stream supports writing.
public long
Length
This property is not supported and always throws a <see cref="T:System.NotSupportedException" /> .
public long
Position
This property is not supported and always throws a <see cref="T:System.NotSupportedException" /> .
public bool
CanTimeout
public int
ReadTimeout
public int
WriteTimeout

Methods

public IAsyncResult
BeginRead​(byte[] buffer, int offset, int count, AsyncCallback? asyncCallback, object asyncState)
Begins an asynchronous read operation. (Consider using the <see cref="M:System.IO.Stream.ReadAsync(System.Byte[],System.Int32,System.Int32)" /> method instead.)
Returns An object that represents the asynchronous read operation, which could still be pending.
buffer The byte array to read the data into.
offset The byte offset 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.
public IAsyncResult
BeginWrite​(byte[] buffer, int offset, int count, AsyncCallback? asyncCallback, object asyncState)
Begins an asynchronous write operation. (Consider using the <see cref="M:System.IO.Stream.WriteAsync(System.Byte[],System.Int32,System.Int32)" /> method instead.)
Returns An object that represents the asynchronous write operation, which could still be pending.
buffer The buffer to write data from.
offset The byte offset 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.
public void
CopyTo​(Stream destination, int bufferSize)
Reads the bytes from the current Deflate stream and writes them to another stream, using a specified buffer size.
destination The stream to which the contents of the current Deflate stream will be copied.
bufferSize The size of the buffer. This value must be greater than zero. The default size is 81920.
CopyToAsync​(Stream destination, int bufferSize, Threading.​CancellationToken cancellationToken)
Asynchronously reads the bytes from the current Deflate stream and writes them to another stream, using a specified buffer size.
Returns A task that represents the asynchronous copy operation.
destination The stream to which the contents of the current Deflate stream will be copied.
bufferSize The size, in bytes, of the buffer. This value must be greater than zero. The default size is 81920.
cancellationToken The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
protected void
Dispose​(bool disposing)
Releases the unmanaged resources used by the <see cref="T:System.IO.Compression.DeflateStream" /> and optionally releases the managed resources.
disposing <see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.
DisposeAsync​()
Asynchronously releases the unmanaged resources used by the <see cref="T:System.IO.Compression.DeflateStream" /> .
Returns A task that represents the asynchronous dispose operation.
public int
EndRead​(IAsyncResult asyncResult)
Waits for the pending asynchronous read to complete. (Consider using the <see cref="M:System.IO.Stream.ReadAsync(System.Byte[],System.Int32,System.Int32)" /> method instead.)
Returns The number of bytes read from the stream, between 0 (zero) and the number of bytes you requested. <see cref="T:System.IO.Compression.DeflateStream" /> returns 0 only at the end of the stream; otherwise, it blocks until at least one byte is available.
asyncResult The reference to the pending asynchronous request to finish.
public void
EndWrite​(IAsyncResult asyncResult)
Ends an asynchronous write operation. (Consider using the <see cref="M:System.IO.Stream.WriteAsync(System.Byte[],System.Int32,System.Int32)" /> method instead.)
asyncResult A reference to the outstanding asynchronous I/O request.
public void
Flush​()
The current implementation of this method has no functionality.
FlushAsync​(Threading.​CancellationToken cancellationToken)
Asynchronously clears all buffers for this Deflate stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.
Returns A task that represents the asynchronous flush operation.
cancellationToken The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
public int
Read​(byte[] buffer, int offset, int count)
Reads a number of decompressed bytes into the specified byte array.
Returns The number of bytes that were read into the byte array.
buffer The array to store decompressed bytes.
offset The byte offset at which the read bytes will be placed.
count The maximum number of decompressed bytes to read.
public int
Read​(Span<​byte> buffer)
Reads a sequence of bytes from the current Deflate stream into a byte span and advances the position within the Deflate stream by the number of bytes read.
Returns The total number of bytes read into the buffer. This can be less than the number of bytes allocated in the buffer if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.
buffer A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current source.
ReadAsync​(byte[] buffer, int offset, int count, Threading.​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.
Returns A task that represents the asynchronous read operation, which wraps the total number of bytes read into the buffer. 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.
buffer The buffer to write the data into.
offset The byte offset 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 <see cref="P:System.Threading.CancellationToken.None" /> .
ReadAsync​(Memory<​byte> buffer, Threading.​CancellationToken cancellationToken = null)
Asynchronously reads a sequence of bytes from the current Deflate stream, writes them to a byte memory range, advances the position within the Deflate stream by the number of bytes read, and monitors cancellation requests.
Returns A task that represents the asynchronous read operation, which wraps the total number of bytes read into the buffer. The result value can be less than the number of bytes allocated in the buffer if that many bytes are not currently available, or it can be 0 (zero) if the end of the Deflate stream has been reached.
buffer The region of memory to write the data into.
cancellationToken The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
public int
ReadByte​()
Reads a byte from the Deflate stream and advances the position within the stream by one byte, or returns -1 if at the end of the Deflate stream.
Returns The unsigned byte cast to an <see cref="T:System.Int32" /> , or -1 if at the end of the stream.
public long
Seek​(long offset, SeekOrigin origin)
This operation is not supported and always throws a <see cref="T:System.NotSupportedException" /> .
Returns A long value.
offset The location in the stream.
origin One of the <see cref="T:System.IO.SeekOrigin" /> values.
public void
SetLength​(long value)
This operation is not supported and always throws a <see cref="T:System.NotSupportedException" /> .
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.
buffer The buffer that contains the data to compress.
offset The byte offset from which the bytes will be read.
count The maximum number of bytes to write.
public void
Write​(ReadOnlySpan<​byte> buffer)
Writes a sequence of bytes to the current Deflate stream and advances the current position within this Deflate stream by the number of bytes written.
buffer A region of memory. This method copies the contents of this region to the current Deflate stream.
WriteAsync​(byte[] buffer, int offset, int count, Threading.​CancellationToken cancellationToken)
Asynchronously writes compressed bytes to the underlying Deflate stream from the specified byte array.
Returns A task that represents the asynchronous write operation.
buffer The buffer that contains the data to compress.
offset The zero-based byte offset 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 <see cref="P:System.Threading.CancellationToken.None" /> .
WriteAsync​(ReadOnlyMemory<​byte> buffer, Threading.​CancellationToken cancellationToken = null)
Asynchronously writes compressed bytes to the underlying Deflate stream from the specified read-only memory region.
Returns A task that represents the asynchronous write operation.
buffer The region of memory to write data from.
cancellationToken The token to monitor for cancellation requests. The default value is <see cref="P:System.Threading.CancellationToken.None" /> .
public void
WriteByte​(byte value)
Writes a byte to the current Deflate stream and advances the current position within this Deflate stream by one.
value A byte to write to the stream.
public void
Close​()
Inherited from Stream
public void
CopyTo​(Stream destination)
Inherited from Stream
CopyToAsync​(Stream destination)
Inherited from Stream
CopyToAsync​(Stream destination, int bufferSize)
Inherited from Stream
CopyToAsync​(Stream destination, Threading.​CancellationToken cancellationToken)
Inherited from Stream
CreateWaitHandle​()
Inherited from Stream
public void
Dispose​()
Inherited from Stream
FlushAsync​()
Inherited from Stream
protected void
ObjectInvariant​()
Inherited from Stream
ReadAsync​(byte[] buffer, int offset, int count)
Inherited from Stream
public int
ReadAtLeast​(Span<​byte> buffer, int minimumBytes, bool throwOnEndOfStream = true)
Inherited from Stream
ReadAtLeastAsync​(Memory<​byte> buffer, int minimumBytes, bool throwOnEndOfStream = true, Threading.​CancellationToken cancellationToken = null)
Inherited from Stream
public void
ReadExactly​(byte[] buffer, int offset, int count)
Inherited from Stream
public void
ReadExactly​(Span<​byte> buffer)
Inherited from Stream
ReadExactlyAsync​(byte[] buffer, int offset, int count, Threading.​CancellationToken cancellationToken = null)
Inherited from Stream
ReadExactlyAsync​(Memory<​byte> buffer, Threading.​CancellationToken cancellationToken = null)
Inherited from Stream
WriteAsync​(byte[] buffer, int offset, int count)
Inherited from Stream
public object
GetLifetimeService​()
Inherited from MarshalByRefObject
public object
InitializeLifetimeService​()
Inherited from MarshalByRefObject
protected MarshalByRefObject
MemberwiseClone​(bool cloneIdentity)
Inherited from MarshalByRefObject
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object