Medium Level: C1ZStreamReader and C1ZStreamWriter Classes

The C1ZStreamReader and C1ZStreamWriter classes allow you to use data compression on any .NET streams, not only in zip files.

To use C1ZStreamReader and C1ZStreamWriter objects, attach them to regular streams and read or write the data through them. The data is compressed (or expanded) on the fly into (or out of) the underlying stream.

This design allows great integration with native .NET streams. The diagram below illustrates how it works:

 

 

For example, the code below saves an ADO.NET DataTable object into a stream and then reads it back:

      Visual Basic

      C#

To add data compression, you would simply add two lines of code:

      Visual Basic

      C#


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.