首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SevenZipSharp:未触发事件

SevenZipSharp:未触发事件
EN

Stack Overflow用户
提问于 2017-09-18 20:06:20
回答 1查看 177关注 0票数 1

我对SevenZipSharp有以下问题。我想压缩一个包含带有完整路径的文件名的列表(字符串)。我的代码运行良好,但只触发了最后一个事件(zip.CompressionFinished)。fFileCompressionStarted和fCompressing都未启动。我做错了什么?

即使我在event-subs或输入"Stop“中设置了断点,也不会发生任何事情。

下面是我的代码:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2018-04-05 23:18:51

很抱歉挖掘这个老问题,但我昨天也在为同样的问题而苦苦挣扎。我发现将FastCompression设置为False会导致事件正确触发。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46278864

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档