0

I need to extract the files out of a ZIP package using VB.Net.

How can this be done without utilizing any external libraries?

2 Answers 2

0

Zipstorer (http://zipstorer.codeplex.com/) is a class that compress/decompress .zip files, it's c#, but if you don't want rely on 3rd party component it's a good solution

0

Yes, you can use the builtin shell functionality for unzipping files. The method to use is CopyHere and this link contains VBScript and VB6 examples along with the flag values that can be used.

To make this work in VB.Net, you add a COM reference to Microsoft Shell Controls and Automation and add code similar to the following:

Public Sub ExtractAll(sSourceFile As String, sTargetDir As String)

    If Not IO.File.Exists(sSourceFile) Then
        Throw New ArgumentException("Source file does not exist", "sSourceFile")
    End If

    If Not IO.Directory.Exists(sTargetDir) Then
        IO.Directory.CreateDirectory(sTargetDir)
    End If

    Dim oShell As New Shell32.Shell
    Dim oOutputDir = oShell.NameSpace(sTargetDir)
    Dim oInput = oShell.NameSpace(sSourceFile)

    ' The value of 4 indicates you don't want the progress dialog to be shown
    oOutputDir.CopyHere(oInput.Items, 4)

End Sub

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.