Results 1 to 4 of 4

Thread: GZipStream extracts only 1/4 of the file

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2008
    Posts
    74

    GZipStream extracts only 1/4 of the file

    This code uncompresses 1/4 of the gzipped file. & I took it directely from the help file sample function codes.

    Any idea why is it doing this or how to fix it? gz file is attached below & it is not damaged.

    Edit: I read some stuff hire & there & found this: tutorial that says that MSDN doesn’t set the size of the array and uses a default size of 4086 bytes. But I have no clue how to implement it into my code.

    In this gz file there are only around 50 lines but there are files with over 1000 lines. So I tested & indeed this seems to be the problem, because if I increase the buffer(4096) more lines are extracted.

    PHP Code:
    Imports System
    Imports System
    .Collections.Generic
    Imports System
    .IO
    Imports System
    .IO.Compression

    Public Class CompressionSnippet

        
    Private Sub CompressionSnippet_Load(ByVal sender As System.ObjectByVal e As System.EventArgsHandles MyBase.Load
            Me
    .Hide()
            
    UncompressFile("1.gz"' Name of the compressed file
            Me.Close()
        End Sub

        Public Shared Sub UncompressFile(ByVal path As String)
            Dim sourceFile As FileStream = File.OpenRead(path)
            Dim destinationFile As FileStream = File.Create(path + ".txt") ' 
    Outputs test.gz.txt

            
    ' Because the uncompressed size of the file is unknown, 
            ' 
    we are imports an arbitrary buffer size.
            
    Dim buffer(4096) As Byte
            Dim n 
    As Integer

            Using input 
    As New GZipStream(sourceFile_
                CompressionMode
    .DecompressFalse)

                
    input.Read(buffer0buffer.Length)
                
    destinationFile.Write(buffer0n)
            
    End Using

            
    ' Close the files.
            sourceFile.Close()
            destinationFile.Close()
        End Sub
    End Class 
    Attached Files Attached Files
    • File Type: gz 1.gz (2.8 KB, 41 views)
    Last edited by goldenix; Mar 9th, 2010 at 12:19 PM.

    M.V.B. 2008 Express Edition

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width