0

I'm trying to make my program extract a .zip file, deliver it's content in a folder, while showing progress in a progressbar. If i somewhat cont get the progressbar thing to work, i would also apprieciate if the "Unzipper" could just switch to another form. Heres the code i currently got for extraction:

    Dim sc As New Shell32.Shell()
    'Create directory in which you will unzip your files .
    IO.Directory.CreateDirectory("C:\Users\NikolajBanke\Desktop\Test\Unzipped")
    'Declare the folder where the files will be extracted
    Dim output As Shell32.Folder = sc.NameSpace("C:\Users\NikolajBanke\Desktop\Test\Unzipped")
    'Declare your input zip file as folder  .
    Dim input As Shell32.Folder = sc.NameSpace("C:\Users\NikolajBanke\Desktop\Test\peace.zip")
    'Extract the files from the zip file using the CopyHere command .
    output.CopyHere(input.Items, 4)

Thank you for any help i would get :)

  • Why does it not work? Do you not see the progress bar, or do you get errors? – Bono Feb 28 '15 at 14:15
  • It does work, but i have no progress bar. I do not knwo how to get the extraction process displayed in the progressbar. :) –  Feb 28 '15 at 15:02

2 Answers2

0

Change output.CopyHere(input.Items, 4) to output.CopyHere(input.Items, 16) Now you get the progress bar.

Allen Hsu
  • 3,515
  • 3
  • 25
  • 38
Thien
  • 1
0

In my opinion ZipArchive is way better, cause you can handle the progressbar event, dont forget to include "System.IO.Compression" reference.

    Public Async Function Extraer(zipFilePath As String, extractPath As String) As Task
    Dim elzip As ZipArchive = ZipFile.OpenRead(zipFilePath)
    Dim lacuenta As Integer = elzip.Entries.Count
    For i = 0 To lacuenta - 1
        Dim entry As ZipArchiveEntry = elzip.Entries(i)
        If entry.Name.Trim = "" Then
            My.Computer.FileSystem.CreateDirectory(Path.Combine(extractPath, entry.FullName))
        Else
            Try
                entry.ExtractToFile(Path.Combine(extractPath, entry.FullName))
            Catch ex As Exception
            End Try
        End If
        ProgressBar1.Value = (i / (lacuenta - 1)) * 100
    Next
End Function