1

Using SevenZipSharp wrapper has anyone succeeded in aborting an in-progress compression? I used:

FileCompressionStarted(ByVal sender As Object, ByVal e As SevenZip.FileNameEventArgs) 

to see some activity and tried:

e.cancel = true 

but nothing happened. Compression continues working until all files are packed. Any ideas?

paradigmatic
  • 40,153
  • 18
  • 88
  • 147
user1797147
  • 915
  • 3
  • 14
  • 33
  • Please provide more information about your issue. – Matt Olan Nov 03 '12 at 21:32
  • ok, so I use this wrapper to pack several files into 7z format (LZMA) and works fine. The problem is when I pass large number of files to compressor, operation can take long especially on non-compressable files and I may need to ABORT operation. So naturally, in the event thrown by library state above, e.cancel should work :( – user1797147 Nov 03 '12 at 22:14

1 Answers1

0

resolved and explained in other forum, please see link, thanks everyone

http://www.vbforums.com/showthread.php?697661-RESOLVED-SevenZipSharp-aborting-compression&p=4272389#post4272389

PS. Just to have solution here, in case anyone needs

e.cancel isn't treated well in library because (like I expected) when I set e.cancel = true once, the library may not catch this request. I'm not sure this is sevenzipsharp.dll problem or 7z.dll but in code posted, when many clicks hits to my Abort button, finally, library aborted compression !!!

So implementation needs to be:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    abort = True
    console.addLine("Abort requested...")
End Sub

Private Sub fFileCompressionStarted(ByVal sender As Object, ByVal e As SevenZip.FileNameEventArgs)

    Dim s As String = ""
    If abort Then
        e.Cancel = True
        s = " aborted"
    End If

    console.addLine("[CompressionStarted event] e.Filename = " + e.FileName + ", e.PercentDone = " + e.PercentDone.ToString + s)



End Sub

Public Sub fCompressionFinished(ByVal sender As Object, ByVal e As System.EventArgs)

    console.addLine("[CompressionFinished event]")
    abort = False
End Sub

Best regards, Edouard Gora, YO3HCV

  • You should not answer your question just to leave messages. People will help you if they can even without these kind of requests! – Marco Nov 04 '12 at 08:37