VB.NET无延迟提取ZIP文件

时间:2017-07-19 07:20:58

标签: vb.net

请Stackoverflow社区寻求帮助。我需要提取ZIP文件而不会抓住应用程序。

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

1 个答案:

答案 0 :(得分:1)

在自己的线程中运行解压缩操作。例如,使用Task(在Windows窗体应用程序中):

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