This uses the ZipInputStream method which provides sequential access
to each entry. The ZipFile method provides random access to each
entry.
The help files have lots of good examples too. They're C# but the
code is very similar to VB.NET.
Note that this was just test code I put together to verify the
decryption functionality since some people reported problems. This is
not really production quality in that it doesn't use try/finally to
ensure all of the streams are properly closed.
HTH,
Sam
Imports System.IO
Imports ICSharpCode.SharpZipLib.Zip
Module Module1
Sub Main()
Dim fileName As String = Path.GetFullPath("../AcapCopy.zip")
Dim destPath As String = Path.GetFullPath("../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()
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)
Loop
outStream.Close()
Loop
inStream.Close()
End Sub
End Module
On Wed, 16 Mar 2005 21:07:09 -0800, Aji Mathews via .NET 247
<an*******@dotnet247.com> wrote:
Hi
I am using SharpZipLib. Could someone help with some sample code to unzip a file to a specified location.
Thanks
--------------------------------
From: Aji Mathews
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>VvXeqg2VFkmm0K5qb1dBJg==</Id>
B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.