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.​ZLibStream

Assembly: System.IO.Compression

Inheritance: object → MarshalByRefObjectStream → ZLibStream

Implemented Interfaces

Provides methods and properties used to compress and decompress streams by using the zlib data format specification.

Properties

public Stream
BaseStream
Gets a reference to the underlying stream.
public bool
CanRead
Gets a value indicating whether the stream supports reading.
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.
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 in <paramref name="buffer" /> 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.
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 in <paramref name="buffer" /> 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 stream and writes them to another stream, using the specified buffer size.
destination The stream to which the contents of the current stream will be copied.
bufferSize The size of the buffer. This value must be greater than zero.
CopyToAsync​(Stream destination, int bufferSize, Threading.​CancellationToken cancellationToken)
Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token.
Returns A task that represents the asynchronous copy operation.
destination The stream to which the contents of the current stream will be copied.
bufferSize The size, in bytes, of the buffer. This value must be greater than zero.
cancellationToken The token to monitor for cancellation requests.
protected void
Dispose​(bool disposing)
DisposeAsync​()
Asynchronously releases all resources used by the stream.
Returns A task that represents the completion of the disposal operation.
public int
EndRead​(IAsyncResult asyncResult)
Waits for the pending asynchronous read to complete.
Returns The number of bytes that were read into the byte array.
asyncResult The reference to the pending asynchronous request to finish.
public void
EndWrite​(IAsyncResult asyncResult)
Ends an asynchronous write operation.
asyncResult The reference to the pending asynchronous request to finish.
public void
Flush​()
Flushes the internal buffers.
FlushAsync​(Threading.​CancellationToken cancellationToken)
Asynchronously clears all buffers for this 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.
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 byte array to read the data into.
offset The byte offset in array at which to begin reading data from the stream.
count The maximum number of bytes to read.
public int
Read​(Span<​byte> buffer)
Reads a number of decompressed bytes into the specified byte span.
Returns The number of bytes that were read into the byte span.
buffer The span to read the data into.
ReadAsync​(byte[] buffer, int offset, int count, Threading.​CancellationToken cancellationToken)
Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.
Returns A task that represents the asynchronous completion of the operation.
buffer The byte array to read the data into.
offset The byte offset in array at which to begin reading data from the stream.
count The maximum number of bytes to read.
cancellationToken The token to monitor for cancellation requests.
ReadAsync​(Memory<​byte> buffer, Threading.​CancellationToken cancellationToken = null)
Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.
Returns A task that represents the asynchronous completion of the operation.
buffer The byte span to read the data into.
cancellationToken The token to monitor for cancellation requests.
public int
ReadByte​()
Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the 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 method is not supported and always throws a <see cref="T:System.NotSupportedException" /> .
Returns This method is not supported and always throws a <see cref="T:System.NotSupportedException" /> .
offset Not supported.
origin Not supported.
public void
SetLength​(long value)
This method is not supported and always throws a <see cref="T:System.NotSupportedException" /> .
value Not supported.
public void
Write​(byte[] buffer, int offset, int count)
Writes compressed bytes to the underlying stream from the specified byte array.
buffer The buffer to write data from.
offset The byte offset in buffer to begin writing from.
count The maximum number of bytes to write.
public void
Write​(ReadOnlySpan<​byte> buffer)
Writes compressed bytes to the underlying stream from the specified byte span.
buffer The buffer to write data from.
WriteAsync​(byte[] buffer, int offset, int count, Threading.​CancellationToken cancellationToken)
Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.
Returns A task that represents the asynchronous completion of the operation.
buffer The buffer to write data from.
offset The byte offset in buffer to begin writing from.
count The maximum number of bytes to write.
cancellationToken The token to monitor for cancellation requests.
WriteAsync​(ReadOnlyMemory<​byte> buffer, Threading.​CancellationToken cancellationToken = null)
Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.
Returns A task that represents the asynchronous completion of the operation.
buffer The buffer to write data from.
cancellationToken The token to monitor for cancellation requests.
public void
WriteByte​(byte value)
Writes a byte to the current position in the stream and advances the position within the stream by one byte.
value The 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