我需要使用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