2012-12-09 48 views
3

我正在使用vb.net並想知道在提取歸檔文件時如何顯示正在提取的文件。我已經有一個解決方法,但它是「巧手」,並沒有真正顯示當前正在提取的文件。SevenZipSharp在提取時顯示當前提取文件

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 

回答

0

這個答案寫在OP但錯誤edited into the question

好吧我知道了。我不得不將「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 
+0

user1888932:如果你有興趣,從這個答案獲得代表處點,請張貼它作爲自己的答案,然後在這裏發表評論,我會刪除這個社會的維基。 – JDB