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.
CloseBaseStream | Whether or not to close the underlying stream. |
CompressionLevel | The compression level to use. |
InputData | Specifies the data to compress or decompress. |
OutputData | The output data after compression or decompression. |
StreamFormat | The 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.
CompressBlock | Compresses a block of data. |
CompressData | Compresses the specified data. |
Config | Sets or retrieves a configuration setting. |
DecompressBlock | Decompresses a block of data. |
DecompressData | Decompresses the specified data. |
GetCompressionStream | Creates an output stream used to write compressed data. |
GetDecompressionStream | Creates an input stream used to read data from a compressed stream. |
Reset | Resets 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.
CompressedData | This event fires with compressed data. |
DecompressedData | This event fires with decompressed data. |
Error | Information 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.
BuildInfo | Information about the product's build. |
GUIAvailable | Tells the component whether or not a message loop is available for processing events. |
LicenseInfo | Information about the current license. |
UseInternalSecurityAPI | Tells the component whether or not to use the system security libraries or an internal implementation. |