3

I'm using vb.net and was wondering how to show what file is being extracted when extracting an archive. I've already have a workaround but it's "cheaty" and doesn't really display the current file that is extracting.

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
JDB
  • 25,172
  • 5
  • 72
  • 123

1 Answers1

0

This answer was written by the OP but incorrectly edited into the question:

Ok I got it. I had to add "FileInfo.FileName" into "SevenZip.FileInfoEventArgs" then make a reference to it when extracting.

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
Community
  • 1
  • 1
JDB
  • 25,172
  • 5
  • 72
  • 123
  • user1888932: If you are interested in gaining rep points from this answer, please post it as your own answer then leave a comment here and I will delete this community wiki. – JDB Sep 17 '13 at 19:08