unzip using SharpZipLib

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aji Mathews via .NET 247

    unzip using SharpZipLib

    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>VvXeqg2VFkm m0K5qb1dBJg==</Id>
  • Samuel R. Neff

    #2
    Re: unzip using SharpZipLib


    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.Sha rpZipLib.Zip

    Module Module1

    Sub Main()
    Dim fileName As String = Path.GetFullPat h("../AcapCopy.zip")
    Dim destPath As String = Path.GetFullPat h("../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()

    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)
    Loop

    outStream.Close ()
    Loop

    inStream.Close( )

    End Sub

    End Module


    On Wed, 16 Mar 2005 21:07:09 -0800, Aji Mathews via .NET 247
    <anonymous@dotn et247.com> wrote:
    [color=blue]
    >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>VvXeqg2VFk mm0K5qb1dBJg==</Id>[/color]

    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.

    Comment

    Working...