使用SevenZipSharp包装器有没有人成功中止正在进行的压缩?我用过:
FileCompressionStarted(ByVal sender As Object, ByVal e As SevenZip.FileNameEventArgs)
看一些活动并尝试过:
e.cancel = true
但没有发生任何事。压缩继续工作,直到所有文件都被打包。有什么想法吗?
答案 0 :(得分:0)
在其他论坛解决并解释,请看链接,谢谢大家
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
祝你好运, Edouard Gora,YO3HCV