3

我正在使用 vb.net 并且想知道在提取档案时如何显示正在提取的文件。我已经有一个解决方法,但它是“作弊的”并且并没有真正显示正在提取的当前文件。

Public Class Form1
    Private listItemIndex As Integer = 0

    Public Sub ext_Extracting(ByVal sender As Object, ByVal e As SevenZip.ProgressEventArgs)
        Dim ext As SevenZipExtractor = New SevenZipExtractor("C:\Test.7z")
        If listItemIndex < ext.ArchiveFileNames.Count Then
            Label1.Text = ext.ArchiveFileNames.Item(listItemIndex).ToString()
            listItemIndex += 1
        End If
    End Sub
End Class
4

1 回答 1

0

这个答案是由 OP 写的,但被错误地编辑成问题

好,我知道了。我必须将“FileInfo.FileName”添加到“SevenZip.FileInfoEventArgs”中,然后在提取时对其进行引用。

Public Sub FileExtractionStarted(ByVal sender As Object, ByVal e As SevenZip.FileInfoEventArgs)
    Label1.Text = e.FileInfo.FileName
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    SevenZipExtractor.SetLibraryPath("C:\7z.dll")
    Dim ext As SevenZipExtractor = New SevenZipExtractor("C:\test.7z")
    ext.BeginExtractArchive("C:\Test")
    AddHandler ext.ExtractionFinished, AddressOf ext_ExtractionFinished
    AddHandler ext.Extracting, AddressOf ext_Extracting
    AddHandler ext.FileExtractionStarted, AddressOf FileExtractionStarted '<---
End Sub
于 2013-09-17T19:06:31.957 回答