SevenZipSharp 有以下问题。我想压缩包含具有完整路径的文件名的列表(字符串)。我的代码工作正常,但只有最后一个事件(zip.CompressionFinished)正在触发。fFileCompressionStarted 和 fCompressing 都没有触发。我究竟做错了什么?
即使我在 event-subs 中设置断点或键入“Stop”,也没有任何反应。
这是我的代码:
Dim working As Boolean
Private Sub start()
Dim zip As New SevenZipCompressor
zip.ArchiveFormat = OutArchiveFormat.SevenZip
zip.CompressionMode = CompressionMode.Create
zip.CompressionLevel = CompressionLevel.Fast
zip.CompressionMethod = CompressionMethod.Lzma2
zip.DirectoryStructure = True
zip.FastCompression = True
zip.IncludeEmptyDirectories = True
zip.PreserveDirectoryRoot = True
zip.TempFolderPath = System.IO.Path.GetTempPath()
AddHandler zip.FileCompressionStarted, AddressOf fFileCompressionStarted
AddHandler zip.Compressing, AddressOf fCompressing
AddHandler zip.CompressionFinished, AddressOf Compress_Finished
working = True
Label10.Text = "Startup..."
Application.DoEvents()
zip.BeginCompressFiles(filename, flist.ToArray)
While working = True
Threading.Thread.Sleep(250)
Application.DoEvents()
End While
End Sub
Private Sub fFileCompressionStarted(ByVal sender As Object, ByVal e As SevenZip.FileNameEventArgs)
Debug.Print(("Compressing " + e.FileName + e.PercentDone.ToString))
Label10.Text = e.FileName
MsVistaProgressBar1.Value = e.PercentDone
Application.DoEvents()
End Sub
Private Sub fCompressing(sender As Object, e As SevenZip.ProgressEventArgs)
MsVistaProgressBar1.Value = e.PercentDone
Application.DoEvents()
End Sub
Private Sub Compress_Finished(sender As Object, e As EventArgs)
MsVistaProgressBar1.Value = 0
Label10.Text = "Ready."
working = False
Application.DoEvents()
End Sub