By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,219 Members | 2,361 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,219 IT Pros & Developers. It's quick & easy.

Unzipping in Visual Basic .Net

P: n/a
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.SharpZipLib.ZipException'
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.SharpZipLib.Zip

This is what I have in my button:

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

Dim fileName As String = Path.GetFullPath("c:\testing.zip")
Dim destPath As String = Path.GetFullPath("c:\unzipped\")

If Not Directory.Exists(destPath) Then
Directory.CreateDirectory(destPath)
Else
For Each s As String In Directory.GetFiles(destPath)
File.Delete(s)
Next
End If

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

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

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

Do While True
bytes = inStream.Read(buff, 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.

Apr 4 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.

Apr 4 '06 #2

P: n/a
Can WinZip open the errant zip file?

Apr 4 '06 #3

P: n/a
Yes, Winzip can open the zip file I need with no problems.

Thanks.

Apr 4 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.