Sevenzip 压缩事件未触发 [英] Sevenzip compressing event not firing

查看:16
本文介绍了Sevenzip 压缩事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 winform 应用程序,它使用 Sevenzip.dll 并实现它的功能以压缩提取文件和目录.我的问题是我想使用 Sevenzip.compressor 类的压缩事件来跟踪压缩进度并用 progressBar 显示它.问题是,事件永远不会触发(在调试模式下检查),而所有其他事件都在工作,例如 CompressionFinished 事件.我发现其他开发人员也遇到了同样的问题,但没有人提供答案.注意:dll 的提取器类也按预期工作,所有事件都在触发,包括extractor.extracting 事件.任何有关如何克服该问题的帮助都将得到帮助.这是我正在使用的一些代码:

I have a winform app the uses the sevenzip.dll and implements it's abilities in order to compress an extract files and directories. My problem is that I want to use the compressing event of the sevenzip.compressor class in order to track the compression progress and display it with progressBar . The thing is , the event never fires (checked in debug mode) , while all other events are working, such as CompressionFinished event . I found that other developers encountered the same problem , but no one provided answers. Note : the extractor class of the dll also work as expected and all events are firing including the extractor.extracting event. Any help on how to overcome the issue will be appriciated. Here is some of the code I am using :

 SevenZipCompressor compressor = new SevenZipCompressor();
            // NOT FIRING
            compressor.Compressing += new EventHandler<ProgressEventArgs>(compressor_Compressing);
            // Firing as expected
            compressor.CompressionFinished += new EventHandler<EventArgs>(compressor_CompressionFinished);
            compressor.ArchiveFormat = OutArchiveFormat.Zip;
            // if this value is true - then no events are fired
            compressor.FastCompression = false;
            compressor.CompressionMethod = CompressionMethod.Default;
            compressor.TempFolderPath = System.IO.Path.GetTempPath();
            compressor.EventSynchronization = EventSynchronizationStrategy.AlwaysAsynchronous;
            compressor.CompressDirectory(source, output, GeneratePassword(backupID, customerID));

推荐答案

为所有遇到相同问题的人找到了答案.

Found an answer to all of you who encountered the same problem.

仅当压缩方法为 lzma 时才会触发压缩事件.

Compressing event fires ONLY if the compressing method is lzma .

只需将一行更改为:

compressor.CompressionMethod = CompressionMethod.Lzma;

这篇关于Sevenzip 压缩事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆