Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

ZipFile - Task not declared


Rekomendowane odpowiedzi

Opublikowano
Cześć wie ktoś może co z tym kodem jest nie tak? Nie deklaruje mi się Task.run.

 


 

 

 

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Private Async Function ExtractAllAsync(zipFilePath As String, extractPath As String, progress As ProgressBar) As Task

        Try

            Dim extractCount, skipCount, errorCount As Integer

            Using archive As ZipArchive = ZipFile.OpenRead(zipFilePath)

                progress.Minimum = 0

                progress.Maximum = archive.Entries.Count

                Await Task.Run(Sub()

                                   Dim count As Integer = archive.Entries.Count

                                   For i As Integer = 0 To count - 1

                                       Try

                                           Dim entry As ZipArchiveEntry = archive.Entries(i)

                                           entry.ExtractToFile(Path.Combine(extractPath, entry.FullName))

                                           extractCount += 1

                                       Catch ioex As IOException

                                           If ioex.Message.EndsWith("already exists.") Then

                                               skipCount += 1

                                           Else

                                               errorCount += 1

                                           End If

                                       Catch ex As Exception

                                           errorCount += 1

                                       End Try

                                       Invoke(Sub() progress.Value += 1)

                                       

                                   Next

                                   

                               End Sub)

            End Using

            MessageBox.Show(String.Format("Poprawnie Zainstalowano {0} Plików, Pominięto {1} Ponieważ już istnieją, wystąpiło {2} błędów.", extractCount, skipCount, errorCount), "Instalacja Zakończona", MessageBoxButtons.OK, MessageBoxIcon.Information)

            progress.Value = 0

        Catch ex As Exception

            MessageBox.Show(ex.Message, "Błąd Przy otwieraniu pliku ZIP", MessageBoxButtons.OK, MessageBoxIcon.Error)

        End Try

    End Function

 

 

    Private Async Sub Panel4_DragDrop(sender As Object, e As DragEventArgs) Handles Panel4.DragDrop

        Dim files As String() = CType(e.Data.GetData(DataFormats.FileDrop), String())

        For Each filename As String In files

            Dim sc As New Shell32.Shell()

            Dim output As Shell32.Folder = sc.NameSpace(My.Application.Info.DirectoryPath)

            Dim input As Shell32.Folder = sc.NameSpace(filename)

            If Path.GetExtension(filename) = ".zip" Then

                Panel4.Enabled = False

                Await ExtractAllAsync(filename, "C:\Users\Crossik\Desktop\test", ProgressBar2)

                Panel4.Enabled = True

            Else

                MsgBox("Tylko rozszerzenie .Zip")

            End If

        Next

    End Sub

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...