GZipStream compressed file is larger than source file

P

prince.matt

Hi,

I am using GZipStream to compress a simple text file approx 24MB in
size. I am finding that the destination "compressed" file is several
MB larger than the source file (31MB). The code is as follows:

Dim sourcefile As FileStream = File.OpenRead(inFileName)
Dim destFile As FileStream = File.Open(outFilename,
FileMode.Create, FileAccess.Write)

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

Any ideas why the compressed file actually ends up larger than the
source?

Thanks,

Matt
 
P

prince.matt

Note, I have experienced the same result when using other files types,
eg: pdf and doc. I even tried using a DeflateStream instead of
GzipStream, and still the destination files are consistently larger
than the source files...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top