This project is read-only.

cancel extraction

May 6, 2010 at 12:47 AM


Could someone help me out.

1. How do I cancel an extraction - i am new to this and need some guidance on this. All help much appreciated.

2. In the Extracting event 'e.PercentDone' seems to be incorrectly displaying the progress percentage (or probably i am doing something wrong). I am extracting a large zip file and monitoring the Extracting event in If i look at the values of percentdone it starts at 1 and goes up to 100. As soon as it gets to 100 any subsequent events will have percentdone = 0 while the file is still being extracted. Could I have some guidance on this? I am using the latest DLL.

Private Sub _zipExtrac_Extracting(ByVal sender As Object, ByVal e As SevenZip.ProgressEventArgs) Handles _zipExtrac.Extracting

<font size="2">


</font>Debug.Print("Percentage: " & e.PercentDone)

End Sub

Thanks, Neil.

May 11, 2010 at 6:57 AM

Zip progress has always been a headache. Only FileExtractionStarted/Finished events guarantee the correctness of progress, since they count it as [number of extracted files]/[total number of files] * 100, whereas Extracting event counts it as [number of bytes read]/[total number of bytes] * 100 and 7-zip reads the same data in ZIP multiple times.

To cancel the extraction, set e.Cancel to true.

Oct 7, 2010 at 3:32 PM
Edited Oct 8, 2010 at 1:10 PM

I have a button that when pressed, sets the "WasCanceled" to true.  I have the following code set to to cancel the extraction if this is true:


Public Sub ExtractFileEvents(ByVal sender As Object, ByVal e As SevenZip.ProgressEventArgs) Handles sze.Extracting
If e.Cancel = True Then
MsgBox("Cancel event raised")
e.Cancel = WasCanceled
End If
End Sub


But the extraction continues.  The msgbox will continue coming up until all files are extracted.  I also have some code for when extraction is completed:


Public Sub ExtractFinished(ByVal sender As Object, ByVal e As System.EventArgs) Handles sze.ExtractionFinished
MsqBox("Extraction Completed")
End Sub

This executes everytime, regardless of cancel.  So it's like the extraction is not respecting the cancel.  Am I missing something or should I be doing this differently?


Jan 20, 2011 at 3:19 PM

I also tried this, i can't seem to get it to work.

Anybody any idea?



Sep 1, 2012 at 3:48 PM
Edited Sep 1, 2012 at 5:10 PM

If anyone comes across this in the future, this is how I did it.

    Private Sub main()

        Label1.Text = "Installing..."
        ' Set library path

        ' Create extractor and specify the archive to extract
        Dim ext As SevenZipExtractor = New SevenZipExtractor("F:\main.pack", "hbTofY&5$%%Z68jMrqKD")
        ' Handlers
        AddHandler ext.ExtractionFinished, AddressOf ext_ExtractionFinished
        AddHandler ext.Extracting, AddressOf ext_Extracting
        AddHandler ext.FileExtractionStarted, AddressOf FileExtractionStarted

        'Start the extraction

    End Sub

    Public Sub FileExtractionStarted(ByVal sender As Object, ByVal e As SevenZip.FileInfoEventArgs)
        If cancelvalue.Text = "1" Then
            e.Cancel = True
        End If
        If e.Cancel = True Then
            MsgBox("Cancel event raised")
        End If
    End Sub

    Private Sub btncancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncancel.Click
        cancelvalue.Text = "1"
    End Sub