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

  • SEARCH
  • Home
  • 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

Related Questions

The code below shows a sample that I've used recently to explain the different
I used the code below to copy from one binary file to another, but
I used the code below to open a binary file fp (the file contain
I used the code below to dynamically create a group of radio buttons: self.wPaymantType.qgbSomeSelectionGroup
i used the code below for my listview and textview . Code: textcontent.setText(Html.fromHtml(item.get_text())); textcontent.setAutoLinkMask(Linkify.WEB_URLS);
I have used the code below to create a button on the nav bar
I made a kernel module and used the code below to try to make
Since the Grid filter is case-sensitive, i used the code below RadGrid1.GroupingSettings.CaseSensitive = false;
I used the code below to get the list of culture type, is there
i want to fetch other than collect value i used below code @boys =

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.