.Net Zipper Class
Lately I have been working on getting some better performance out of a couple of my .net apps that pass large amounts of data across the network. While doing this I wrote a wrapper class for system.io.compression.gzipstream which I thought I would share.
The class exposed 4 public static methods.
byte[] GZipBytetoByte(Byte[] GzippedBuffer) – Takes a gzipped byte array and returns the unzipped byte array.
byte[] BytetoGZipByte(byte[] buffer) – Takes a byte array and returns the zipped version of that byte array.
byte[] GzipfiletoByte(string filepath) – Unzips a file previously zipped by the zipper class and return a byte array of the unzipped data.
void BytetoGZipFile(string filepath, byte[] buffer) – Takes an unzipped byte array, zips it and writes it a file.
The GzipBytetoByte and BytetoGZipByte methods are useful to me because they allow for the zipping and unzipping of byte array data in memory, which means that I can compress blobs before I write them to SQL, and compress large chunks of binary before it is sent across the network.
The system.io.compression.gzipstream seems to be giving me about about 85% compression with very little overhead.
The class exposed 4 public static methods.
byte[] GZipBytetoByte(Byte[] GzippedBuffer) – Takes a gzipped byte array and returns the unzipped byte array.
byte[] BytetoGZipByte(byte[] buffer) – Takes a byte array and returns the zipped version of that byte array.
byte[] GzipfiletoByte(string filepath) – Unzips a file previously zipped by the zipper class and return a byte array of the unzipped data.
void BytetoGZipFile(string filepath, byte[] buffer) – Takes an unzipped byte array, zips it and writes it a file.
The GzipBytetoByte and BytetoGZipByte methods are useful to me because they allow for the zipping and unzipping of byte array data in memory, which means that I can compress blobs before I write them to SQL, and compress large chunks of binary before it is sent across the network.
The system.io.compression.gzipstream seems to be giving me about about 85% compression with very little overhead.
0 Comments:
Post a Comment
<< Home