Compresses data into .NET Streams.
Namespace:
C1.C1ZipAssembly: C1.Silverlight.Zip (in C1.Silverlight.Zip.dll)
Syntax
Remarks
To compress data into a stream, create a C1ZStreamWriter object passing the stream to the C1ZStreamWriter constructor.
Then write the data into the C1ZStreamWriter using the Write(array<Byte>[]()[][], Int32, Int32) method, or create a StreamWriter on the C1ZStreamWriter. The second option is indicated when you want to write formatted data.
When you are done writing the data, call the Close()()()() method to flush the data and close the underlying stream.
Examples
The code below compresses a string into a memory stream:
Copy CodeC#

public byte[] CompressString(string str) { // open memory stream var ms = new MemoryStream(); // attach compressor stream to memory stream var sw = new C1ZStreamWriter(ms); // write data into compressor stream var writer = new StreamWriter(sw); writer.Write(str); // flush any pending data writer.Flush(); // return the memory buffer return ms.ToArray(); } |
Inheritance Hierarchy
System..::..Object
System..::..MarshalByRefObject
System.IO..::..Stream
C1.C1Zip..::..C1ZStreamWriter
System..::..MarshalByRefObject
System.IO..::..Stream
C1.C1Zip..::..C1ZStreamWriter