1

使用 SevenZipSharp 包装器是否有人成功中止正在进行的压缩?我用了:

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

查看一些活动并尝试:

e.cancel = true 

但什么也没发生。压缩继续工作,直到所有文件都被打包。有任何想法吗?

4

1 回答 1

0

已在其他论坛解决和解释,请看链接,谢谢大家

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

PS。只是在这里有解决方案,以防万一有人需要

e.cancel在库中没有得到很好的处理,因为(如我所料)当我设置e.cancel = true一次时,库可能无法捕获此请求。我不确定这是sevenzipsharp.dll 问题还是7z.dll,但是在发布的代码中,当多次点击我的Abort 按钮时,最后,库中止了压缩!!!

所以实现需要:

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

最好的问候,爱德华·戈拉,YO3HCV

于 2012-11-04T08:16:30.773 回答