i am getting this error
what might be the reason

The magic number in GZip header is not correct. Make sure you are passing in a GZip stream.

Sub DeCompress(ByVal zipFile As String, ByVal destimnationfile As String)
Dim zf As FileStream = File.OpenRead(zipFile)
Dim df As FileStream = File.Create(destimnationfile)
Dim gzs As New GZipStream(zf, CompressionMode.Decompress)
Dim b As Int32 = zf.ReadByte()
While gzs.ReadByte <> -1
df.WriteByte(CType(b, Byte))
b = gzs.ReadByte()
End While


End Sub

sub main()
DeCompress("C:\lot.txt.gz", "C:\lot.txt")
end sub

could u please tel me the reason for this

Re: Visual Basic General The magic number in GZip header is not correct.!

Bruno Yu - MSFT


This is a common question. I would like to provide you the similar threads with the solutions:

1. PostID=427166&SiteID=1

A 'Magic Number' is usually a fixed value, and often appearing somewhat arbitary, possibly indecipherable. For example, a line of code may have:

If X = 31 then
'Do Something
End If

In this case, 31 is a 'Magic Number': It has no obvious meaning (and as far as coding is concerned, a term of derision).

Files (of different types) often have the first few bytes set to certain values, for example, a file which has the first two bytes as then hexadecimal numbers 42 4D is a Bitmap file. These numbers are 'magic numbers' (In this case, 42 4D corresponds to the characters BM). Other files have similar 'magic numbers'.

2. postid=1154042&siteid=1

Of course, the minute someone (team) develops a no-fuss compression/decompression custom task which supports zip,bzip2, gzip, rar, cab, jar, daa and iso files, I'll use that, until that time, I'll stick with the open source command line utilities.

Of course you can code up a solution, but this one is such low hanging fruit. For handling zip files, there is no native .NET library (at least not yet). Now there is support is for handling the compressed streams INSIDE the zip file, but not navigating the archive itself.

Now, as I mentioned in a previously, there are plenty of open source zip utils like those on sourceforge. These work fine on Win2003 Server x64, I can attest to that.

However, if you're insistent on a .NET solution for zip decompression, use, which is open source, and which has a clean and reliable 100% .NET implementation.