Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 118519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:30:27+00:00 2026-05-11T03:30:27+00:00

I used the code below to compress files and they keep growing instead of

  • 0

I used the code below to compress files and they keep growing instead of shrinking. I comressed a 4 kb file and it became 6. That is understandable for a small file because of the compression overhead. I tried a 400 mb file and it became 628 mb after compressing. What is wrong? See the code. (.net 2.0)

Public Sub Compress(ByVal infile As String, ByVal outfile As String)     Dim sourceFile As FileStream = File.OpenRead(inFile)     Dim destFile As FileStream = File.Create(outfile)      Dim compStream As New GZipStream(destFile, CompressionMode.Compress)      Dim myByte As Integer = sourceFile.ReadByte()     While myByte <> -1         compStream.WriteByte(CType(myByte, Byte))         myByte = sourceFile.ReadByte()     End While      sourceFile.Close()     destFile.Close() End Sub 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:30:27+00:00Added an answer on May 11, 2026 at 3:30 am

    Are you sure that writing byte by byte to the stream is a really good idea? It will certainly not have ideal performance characteristics and maybe that’s what confuses the gzip compressing algorithm too.

    Also, it might happen that the data you are trying to compress is just not really well-compressable. If I were you I would try your code with a text document of the same size as text documents tend to compress much better than random binary.

    Also, you could try using a pure DeflateStream as opposed to a GZipStream as they both use the same compression algorithm (deflate), the only difference is that gzip adds some additional data (like error checking) so a DeflateStream might yield smaller results.

    My VB.NET is a bit rusty so I’ll rather not try to write a code example in VB.NET. Instead, here’s how you should do it in C#, it should be relatively straightforward to translate it to VB.NET for someone with a bit of experience: (or maybe someone who is good at VB.NET could edit my post and translate it to VB.NET)

    FileStream sourceFile; GZipStream compStream;  byte[] buffer = new byte[65536]; int bytesRead = 0; while (bytesRead = sourceFile.Read(buffer, 0, 65536) > 0) {      compStream.Write(buffer, 0, bytesRead); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 101k
  • Answers 101k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Content-Disposition header.. // We'll be outputting a PDF header('Content-type: application/pdf');… May 11, 2026 at 8:08 pm
  • Editorial Team
    Editorial Team added an answer An object graph is not a single object, but rather… May 11, 2026 at 8:08 pm
  • Editorial Team
    Editorial Team added an answer Try this regular expression: ^(?:[01]?[0-9]|2[0-3]):[0-5][0-9]$ Or to be more distinct:… May 11, 2026 at 8:08 pm

Related Questions

I'm on Ubuntu Intrepid and I'm using jpeglib62 6b-14. I was working on some
I am using the following code to play a sound file using the java
I have a class SomeClass, which can populate itself from a datarow in it's
I am connecting to CRM with the intention of retrieving a list of picklist

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.