Zlib. Net wrapper
Documents: http://zlibnetwrapper.sourceforge.net/
Here are some reference codes: (document translation)
Compressionstream-stream encapsulation can be used to compress or decompress data using zlib's compression and decompression functions.
Zlibexception-zlib generates an exception encapsulation class.
Compress-binarywriter-packing compressionstream object Encapsulation
Decompress a binaryreader-packing of encapsulated compressionstream objects
Base64stream-stream-derived class is used to encode or decode base-64 text data.
Managedzlib. compressionstream: system. Io. Stream
Compressionstream (Stream stream, compressionoptions option)
Compressionoptions Option
Compressionoptions. Decompress-extract data.
Compressionoptions. Compress-use the default compression level to compress data.
Compressionoptions. compressnone-do not compress data (add header information)
Compressionoptions. compressfast-use the fastest compression method.
Compressionoptions. compresslevelzero-same as compressionoptions. compressnone.
Compressionoptions. compresslevelone-same as compressionoptions. compressfast.
Compressionoptions. compressleveltwo-compression uses better compression but is slow.
Compressionoptions. compresslevelthree
Compressionoptions. compresslevelfour
Static string zlibversion
Return version
Static compressionoptions getlevel (INT level
Convert the number (0-9) into a compressionoptions enumeration. The invalid number is converted to the default compression level. The following attributes are used to obtain information compression or decompression. All these features are streamable and disabled.
Unsigned int CRC returns the CRC information of uncompressed data.
Unsigned long bytesin write stream/Read Source Value
Unsigned long bytesout: number of data written to the Target stream/read stream
Double compressionratio compression rate
Managedzlib. base64stream: system. Io. Stream
Base64stream (Stream stream, base64options option)
Base64options. encode-encode into base-64 data stream. Encoding
Base64options. Decode-Decode base-64 data stream. Decoding
Reference Code
Managedzlib. managedzlib. initialize ();
// Initialization. It is very important that you forget that I can't do it.
Managedzlib. compressionstream zlibstream = new managedzlib. compressionstream (datastream, managedzlib. compressionoptions. Decompress );
// Datastream is the source. For example, if memorystream is used, the basic stream is used to read, compress, or compress written data.
Binaryreader zlibreader = new binaryreader (zlibstream );
Memorystream memorystreamdecompressed = NULL;
Try {
Byte [] decompressedpart = new byte [filelength];
// Filelength file length
Zlibreader. Read (decompressedpart, 0, decompressedpart. Length); // decompress and compress.
Memorystreamdecompressed = new memorystream (decompressedpart );
} Finally {
If (memorystreamdecompressed! = NULL)
Memorystreamdecompressed. Close ();
Zlibreader. Close ();
Zlibstream. Close ();
Managedzlib. managedzlib. Terminate (); // release the resource. Do not forget it.
}