0

我试图让我的程序提取一个 .zip 文件,将其内容交付到一个文件夹中,同时在进度条中显示进度。如果我有点继续让进度条工作,如果“解压缩器”可以切换到另一种形式,我也会很高兴。这是我目前提取的代码:

    Dim sc As New Shell32.Shell()
    'Create directory in which you will unzip your files .
    IO.Directory.CreateDirectory("C:\Users\NikolajBanke\Desktop\Test\Unzipped")
    'Declare the folder where the files will be extracted
    Dim output As Shell32.Folder = sc.NameSpace("C:\Users\NikolajBanke\Desktop\Test\Unzipped")
    'Declare your input zip file as folder  .
    Dim input As Shell32.Folder = sc.NameSpace("C:\Users\NikolajBanke\Desktop\Test\peace.zip")
    'Extract the files from the zip file using the CopyHere command .
    output.CopyHere(input.Items, 4)

感谢您为我提供的任何帮助:)

4

2 回答 2

0

更改output.CopyHere(input.Items, 4)output.CopyHere(input.Items, 16) 现在您获得进度条。

于 2015-05-06T01:49:48.827 回答
0

在我看来 ZipArchive 更好,因为您可以处理进度条事件,不要忘记包含“System.IO.Compression”参考。

    Public Async Function Extraer(zipFilePath As String, extractPath As String) As Task
    Dim elzip As ZipArchive = ZipFile.OpenRead(zipFilePath)
    Dim lacuenta As Integer = elzip.Entries.Count
    For i = 0 To lacuenta - 1
        Dim entry As ZipArchiveEntry = elzip.Entries(i)
        If entry.Name.Trim = "" Then
            My.Computer.FileSystem.CreateDirectory(Path.Combine(extractPath, entry.FullName))
        Else
            Try
                entry.ExtractToFile(Path.Combine(extractPath, entry.FullName))
            Catch ex As Exception
            End Try
        End If
        ProgressBar1.Value = (i / (lacuenta - 1)) * 100
    Next
End Function
于 2016-11-09T05:14:58.890 回答