This project is read-only.

Ionic.zlib.gzipstream not unzipping entire file

Jun 29, 2016 at 2:38 PM
Hi experts,
  I am unzipping the file. The file is gzip. I am using GZipStream with CompressionMode.Decompress
It is working means extracting the file but only top 10 lines only. If I extract manually with 7gip, the file is extracted full with the size 58MB. Using the code, it is extracting only 10KB or like that.

It's not giving any error but just extracting only small portion of the file.

How can I debug? What could be the issue? It is working well previously. I don't know what is the difference between old and new files. It's not generating any errors.

If I manually unzip and zip again, the code working well.

My code as below

Dim DecompressedFile As String = NewZipFile.Substring(0, NewZipFile.Length - 3)
        Dim working(2048) As Byte
        Dim n As Integer = 1
        Using input As Stream = File.OpenRead(NewZipFile)
            Using decompressor As Stream = New Ionic.Zlib.GZipStream(input, CompressionMode.Decompress, True)

                Using output As Stream = File.Create(DecompressedFile)
                        n = decompressor.Read(working, 0, working.Length)

                        If n > 0 Then
                            output.Write(working, 0, n)
                        End If
                    Loop While (n > 0)
                End Using
            End Using
        End Using