ZipStream Component

Properties   Methods   Events   Configuration Settings   Errors  

The ZipStream component is used to perform compression or decompression.

Syntax

nsoftware.IPWorksZip.Zipstream

Remarks

The ZipStream component provides a way to compress and decompress streamed data.

Data may be operated on in multiple ways as discussed below. The StreamFormat property specifies the algorithm to us. Possible values are:

  • Deflate
  • Zlib
  • Gzip

Compression and Decompression Streams

The GetDecompressionStream and GetCompressionStream methods are used to retrieve streams that read or write compressed data, as appropriate; the underlying stream should be passed to either method as a parameter.

CompressBlock and DecompressBlock

The CompressBlock and DecompressBlock methods operate on blocks (chunks) of data. The methods may be used to compress and decompress data as it becomes available.

Note that when using blocks of data the OutputData property is not applicable. Instead data is made available through the CompressedData and DecompressedData events.

If all data is available ahead of time CompressData and DecompressData may be called instead.

Compress Data

Set InputData to the current block to be compressed. Next call CompressBlock to compress the current block. Note that CompressBlock takes a LastBlock parameter. If the block of data is the final block to be compressed set this to True. For all other blocks set this to False.

During compression the CompressedData event will fire with the compressed data. Note that this event may not fire for every call to CompressBlock due to the way the compression algorithm operates. For example:


zipstream.InputDataB = MyDecompressedData;
zipstream.CompressBlock();
Data is accumulated inside the CompressedData event:
private static void Zipstream_OnCompressedData(object sender, ZipstreamCompressedDataEventArgs e)
{
  DoSomethingWith(e.DataB);
}

Note that OutputData is not applicable when compressing block data.

Decompress Data

Set InputData to the current block to be decompressed. Next call DecompressBlock to decompress the current block.

During decompression the DecompressedData event will fire with the decompressed data. Note that this event may not fire for every call to DecompressBlock due to the way the decompression algorithm operates. For example:


zipstream.InputDataB = MyCompressedData;
zipstream.DecompressBlock();
Data is accumulated inside the DecompressedData event:
private static void Zipstream_OnDecompressedData(object sender, ZipstreamDecompressedDataEventArgs e)
{
  DoSomethingWith(e.DataB);
}

Note that OutputData is not applicable when decompressing block data.

CompressData and DecompressData

The CompressData and DecompressData methods operate on the complete blob of data. The entire compressed or decompressed data must be set to InputData before calling either method.

To compress and decompress data in blocks (chunks) see CompressBlock and DecompressBlock.

Compress Data

Set InputData to the decompressed data. This should be the entire data to be compressed. Next call CompressData. After compression OutputData will hold the compressed data. For example:


zipstream.InputDataB = MyDecompressedData;
zipstream.CompressData();
MyCompressedData = zipstream.OutputDataB;

In addition to OutputData, the compressed data may also be accumulated within the CompressedData event.

Decompress Data

Set InputData to the compressed data. This should be the entire data to be decompressed. Next call DecompressData. After decompression OutputData will hold the decompressed data. For example:


zipstream.InputDataB = MyCompressedData;
zipstream.DecompressData();
MyDecompressedData = zipstream.OutputDataB;

In addition to OutputData, the compressed data may also be accumulated within the DecompressedData event.

Property List


The following is the full list of the properties of the component with short descriptions. Click on the links for further details.

CloseBaseStreamWhether or not to close the underlying stream.
CompressionLevelThe compression level to use.
InputDataSpecifies the data to compress or decompress.
OutputDataThe output data after compression or decompression.
StreamFormatThe stream format to use.

Method List


The following is the full list of the methods of the component with short descriptions. Click on the links for further details.

CompressBlockCompresses a block of data.
CompressDataCompresses the specified data.
ConfigSets or retrieves a configuration setting.
DecompressBlockDecompresses a block of data.
DecompressDataDecompresses the specified data.
GetCompressionStreamCreates an output stream used to write compressed data.
GetDecompressionStreamCreates an input stream used to read data from a compressed stream.
ResetResets the component.

Event List


The following is the full list of the events fired by the component with short descriptions. Click on the links for further details.

CompressedDataThis event fires with compressed data.
DecompressedDataThis event fires with decompressed data.
ErrorInformation about errors during data delivery.

Configuration Settings


The following is a list of configuration settings for the component with short descriptions. Click on the links for further details.

BuildInfoInformation about the product's build.
GUIAvailableTells the component whether or not a message loop is available for processing events.
LicenseInfoInformation about the current license.
UseInternalSecurityAPITells the component whether or not to use the system security libraries or an internal implementation.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks ZIP 2020 .NET Edition - Version 20.0 [Build 8300]