Zdeněk Grůza
Zdeněk Grůza

Reputation: 13

VB.NET Extract ZIP File without lag

Please Stackoverflow community for help. I need to Extract the ZIP File without snagging the app.

Using zip1 As ZipFile = ZipFile.Read(".\packageData\" + zip.Text + ".zip")
            Dim Z As ZipEntry

            For Each Z In zip1
                Z.Extract(".\apps\", ExtractExistingFileAction.OverwriteSilently)
            Next
        End Using

Upvotes: 0

Views: 137

Answers (1)

Ondřej
Ondřej

Reputation: 1673

Run that unzipping operation in its own thread. For example using Task (in Windows Forms application):

Private Async Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  Dim worker As New Task(Sub()
                           Using zip1 As ZipFile = ZipFile.Read(".\packageData\" + zip.Text + ".zip")
                             Dim Z As ZipEntry

                             For Each Z In zip1
                               Z.Extract(".\apps\", ExtractExistingFileAction.OverwriteSilently)
                             Next
                           End Using
                         End Sub)
  worker.Start()
  Await worker
  MsgBox("Done.")
End Sub

Upvotes: 1

Related Questions