Unzipping in Visual Basic .Net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ILCSP@NETZERO.NET

    Unzipping in Visual Basic .Net

    Hello, I've been trying to unzip a file in Visual Basic .Net (03) but
    I'm getting an error. I do get the destination directory and I do get
    the first extracted file, but then it stops and I get an wrong local
    header signature error. I've added the SharpZipLib.dll library to my
    project, so that's what I'm using. The zip files contains 9 text
    files.

    This is the error I get:
    An unhandled exception of type 'ICSharpCode.Sh arpZipLib.ZipEx ception'
    occurred in sharpziplib.dll
    Additional information: Wrong Local header signature-1826153501

    I have the following in the top of my code:
    Imports System
    Imports System.IO
    Imports ICSharpCode.Sha rpZipLib.Zip

    This is what I have in my button:

    Private Sub btnUnzip_Click( ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles btnUnzip.Click

    Dim fileName As String = Path.GetFullPat h("c:\testing.z ip")
    Dim destPath As String = Path.GetFullPat h("c:\unzipped\ ")

    If Not Directory.Exist s(destPath) Then
    Directory.Creat eDirectory(dest Path)
    Else
    For Each s As String In Directory.GetFi les(destPath)
    File.Delete(s)
    Next
    End If

    Dim inStream As New ZipInputStream( File.OpenRead(f ileName))
    Dim outStream As FileStream

    Dim entry As ZipEntry
    Dim buff(2047) As Byte
    Dim bytes As Integer

    Do While True
    entry = inStream.GetNex tEntry() <==== This is where the
    error occurs!
    If entry Is Nothing Then
    Exit Do
    End If
    outStream = File.Create(des tPath + entry.Name, 2048)

    Do While True
    bytes = inStream.Read(b uff, 0, 2048)
    If bytes = 0 Then
    Exit Do
    End If
    outStream.Write (buff, 0, bytes)
    MsgBox("writing ")
    Loop
    outStream.Close ()
    Loop
    inStream.Close( )
    End Sub

    Any help would be greatly appreciated.

    Thanks.

  • ILCSP@NETZERO.NET

    #2
    Re: Unzipping in Visual Basic .Net

    Hello again, I just want to point out that I created a new zip file
    with Winzip with 2 text files in it and tested the code and it worked.
    However, when I tested again the Zip file I actually need to unzip, I
    still get the Wrong Local header signature-1826153501 error.

    Comment

    • zacks@construction-imaging.com

      #3
      Re: Unzipping in Visual Basic .Net

      Can WinZip open the errant zip file?

      Comment

      • ILCSP@NETZERO.NET

        #4
        Re: Unzipping in Visual Basic .Net

        Yes, Winzip can open the zip file I need with no problems.

        Thanks.

        Comment

        Working...