I want to Compress an Object in dot net to reduce its size and then UnCompress it on in my client application.
Thanks, Mrinal Jaiswal
I want to Compress an Object in dot net to reduce its size and then UnCompress it on in my client application.
Thanks, Mrinal Jaiswal
I have update the code there was a problem with older version.
Here is a function which serialize and compress and viceversa.
Following is how to use it.
But there is a catch to compression. Remember the above example object is serialize to 153 bytes but the compress version is 266 bytes the reason is that if have small objects with less data then the gzip header information and compression header will at least take 120bytes. So if your object are big enough than compress them if they are just less 300 bytes or so its no need to compress them. You can check compression ratio and see if you object even require compression.
Another suggestion try to compress bulk of data will always give better compression over individual compress objects.
Serialize it simply by adding the following above your class: (maybe take a look at: http://blog.kowalczyk.info/article/Serialization-in-C.html to fully understand how it works.)
You can always GZip it.
I suppose you need to improve the serialization procedure, by compressing the contained data. Once I needed that in .NET, I used SoapExtensions, but you can also use httpmodule's functionality like msdn proposed: