Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Issue with the GzipStream Class

Issue with the GzipStream Class

Scheduled Pinned Locked Moved C#
helpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ramz_g
    wrote on last edited by
    #1

    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

    R 1 Reply Last reply
    0
    • R 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

      R Offline
      R Offline
      Rolando CC
      wrote on last edited by
      #2

      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:

      R 1 Reply Last reply
      0
      • R Rolando CC

        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:

        R Offline
        R Offline
        ramz_g
        wrote on last edited by
        #3

        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

        R 1 Reply Last reply
        0
        • R 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

          R Offline
          R Offline
          Rolando CC
          wrote on last edited by
          #4

          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:

          R 1 Reply Last reply
          0
          • R Rolando CC

            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:

            R Offline
            R Offline
            ramz_g
            wrote on last edited by
            #5

            Hi Rolcr, :-) Ya.. Even i browsed through all these sites earlier today and found that there are some issues with GZipStream... Anyways, thanks for the replies... ramz_g

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups