VB.NET使用Progressbar提取ZIP文件

时间:2017-11-07 14:43:40

标签: vb.net

我需要使用Progressbar解压缩ZIP文件,所以我制作了这段代码。

    Private Async Sub Downloader_DownloadFileCompleted(sender As Object, e As AsyncCompletedEventArgs) Handles Downloader.DownloadFileCompleted
    Dim worker As New Task(Sub()
                               Dim username As String
                               username = Environment.UserName
                               ZipToUnpack = "C:\Users\" & username & "\Documents\InfinityHexLauncher\Instances\InfinityHex.zip"
                               Ziel = "C:\Users\" & username & "\Documents\InfinityHexLauncher\Instances"

                               Using zip As ZipFile = ZipFile.Read("C:\Users\" & username & "\Documents\InfinityHexLauncher\Instances\InfinityHex.zip")
                                   Dim Entry As ZipEntry
                                   For Each Entry In zip
                                       AddHandler zip.ExtractProgress, AddressOf MEP
                                       Entry.Extract(Ziel, ExtractExistingFileAction.OverwriteSilently)
                                   Next
                               End Using
                           End Sub)
    worker.Start()
    Await worker
End Sub

我现在没有任何延迟,但没有进度条,也不知道它......

    Private Sub MEP(sender As Object, e As ExtractProgressEventArgs)
        byteszip.Text = e.BytesTransferred
    End Sub

0 个答案:

没有答案