Issue with the GzipStream Class
-
Hi, I am trying to include a compression mechanism in my application. I just went through the one that microsoft provides : GZipStream class... I used the sample code given in msdn and tried to compress files... It worked well for text and document files... But when i tried to compress an exe file, say 100mb size, the compressed file that i get is of size more than 130mb... Can anyone please tell me whether this is a problem with the GZipStream Class? Thanks in advance, ramz_g
-
Hi, I am trying to include a compression mechanism in my application. I just went through the one that microsoft provides : GZipStream class... I used the sample code given in msdn and tried to compress files... It worked well for text and document files... But when i tried to compress an exe file, say 100mb size, the compressed file that i get is of size more than 130mb... Can anyone please tell me whether this is a problem with the GZipStream Class? Thanks in advance, ramz_g
Hi, First: Is more easy to compress text files than .exe, Second: From msdn: http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream.aspx[^] The compression functionality in DeflateStream and GZipStream is exposed as a stream. Data is read in on a byte-by-byte basis, so it is not possible to perform multiple passes to determine the best method for compressing entire files or large blocks of data. The DeflateStream and GZipStream classes are best used on uncompressed sources of data. If the source data is already compressed, using these classes may actually increase the size of the stream. So I think in some way maybe the .exe is already compressed. :suss:
-
Hi, First: Is more easy to compress text files than .exe, Second: From msdn: http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream.aspx[^] The compression functionality in DeflateStream and GZipStream is exposed as a stream. Data is read in on a byte-by-byte basis, so it is not possible to perform multiple passes to determine the best method for compressing entire files or large blocks of data. The DeflateStream and GZipStream classes are best used on uncompressed sources of data. If the source data is already compressed, using these classes may actually increase the size of the stream. So I think in some way maybe the .exe is already compressed. :suss:
Hi Rolcr, Thanks for the reply. And yes, I could understand that using those classes to compress files that are already compressed may increase the size. But there is something interesting. I downloaded the gzip.exe from GNU's website and used it to compress a few files. I could find that the size of an exe file reduced by about 5mb... Whereas, using the above classes, the size of the same file increased by more than 30mb. Also, both (gzip.exe and the GZipStream class) returned similar results when applied to .txt and .doc files. Please give me your opinion on this. Thanks, ramz_g
-
Hi Rolcr, Thanks for the reply. And yes, I could understand that using those classes to compress files that are already compressed may increase the size. But there is something interesting. I downloaded the gzip.exe from GNU's website and used it to compress a few files. I could find that the size of an exe file reduced by about 5mb... Whereas, using the above classes, the size of the same file increased by more than 30mb. Also, both (gzip.exe and the GZipStream class) returned similar results when applied to .txt and .doc files. Please give me your opinion on this. Thanks, ramz_g
Yeah, I have listen that in other webs, and seems to be a problem with the GZipStream class and files that had been already compressed, check this: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=93636[^][^] Workaround? Use : http://www.codeplex.com/DotNetZip[^] :cool:
-
Yeah, I have listen that in other webs, and seems to be a problem with the GZipStream class and files that had been already compressed, check this: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=93636[^][^] Workaround? Use : http://www.codeplex.com/DotNetZip[^] :cool: