Zlib. Net wrapper document Chinese Translation Reference Code

Source: Internet
Author: User

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.
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.