ZlibStream

class ZlibStream : System.IO.Stream, System.IDisposable

Represents a Zlib stream for compression or decompression.

FlushType FlushMode

This property sets the flush behavior on the stream. Sorry, though, not sure exactly how to describe all the various settings.

int BufferSize

The size of the working buffer for the compression codec.

readonly long TotalIn

Returns the total number of bytes input so far.

readonly long TotalOut

Returns the total number of bytes output so far.

readonly bool CanRead

Indicates whether the stream can be read.

readonly bool CanSeek

Indicates whether the stream supports Seek operations.

readonly bool CanWrite

Indicates whether the stream can be written.

readonly long Length

Reading this property always throws a T:System.NotSupportedException.

long Position

The position of the stream pointer.

public void Flush()

Flush the stream.

public int Read(System.Byte[] buffer, int offset, int count)

Read data from the stream.

Parameters:
  • buffer (System.Byte[]) – The buffer into which the read data should be placed.
  • offset (int) – the offset within that data array to put the first byte read.
  • count (int) – the number of bytes to read.
Returns:

the number of bytes read

public long Seek(long offset, System.IO.SeekOrigin origin)

Calling this method always throws a T:System.NotSupportedException.

Parameters:
  • offset (long) – The offset to seek to…. IF THIS METHOD ACTUALLY DID ANYTHING.
  • origin (System.IO.SeekOrigin) – The reference specifying how to apply the offset…. IF THIS METHOD ACTUALLY DID ANYTHING.
Returns:

nothing. This method always throws.

public void SetLength(long value)

Calling this method always throws a T:System.NotSupportedException.

Parameters:
  • value (long) – The new value for the stream length…. IF THIS METHOD ACTUALLY DID ANYTHING.
public void Write(System.Byte[] buffer, int offset, int count)

Write data to the stream.

Parameters:
  • buffer (System.Byte[]) – The buffer holding data to write to the stream.
  • offset (int) – the offset within that data array to find the first byte to write.
  • count (int) – the number of bytes to write.
public System.Byte[] CompressString(string s)

Compress a string into a byte array using ZLIB.

Parameters:
  • s (string) – A string to compress. The string will first be encoded using UTF8, then compressed.
Returns:

The string in compressed form

public System.Byte[] CompressBuffer(System.Byte[] b)

Compress a byte array into a new byte array using ZLIB.

Parameters:
  • b (System.Byte[]) – A buffer to compress.
Returns:

The data in compressed form

public string UncompressString(System.Byte[] compressed)

Uncompress a ZLIB-compressed byte array into a single string.

Parameters:
  • compressed (System.Byte[]) – A buffer containing ZLIB-compressed data.
Returns:

The uncompressed string

public System.Byte[] UncompressBuffer(System.Byte[] compressed)

Uncompress a ZLIB-compressed byte array into a byte array.

Parameters:
  • compressed (System.Byte[]) – A buffer containing ZLIB-compressed data.
Returns:

The data in uncompressed form