zoukankan      html  css  js  c++  java
  • 处理sevenzipsharp 检查密码函数的Bug

    using (SevenZipExtractor extr = new SevenZipExtractor(tbPackagePath.Text, "www.pc6.com"))
                {
    
                    if (extr.Check())
                    {
                        MessageBox.Show("密码正确");
                    }
                    else
                    {
                        MessageBox.Show("密码不正确");
                    }
                }

    这一段是检查压缩包密码是否正确,发现360压缩的zip,不管正不正确,都返回true,

    修改以下源码(ArchiveExtractCallback.cs),避免此错误

    public void SetOperationResult(OperationResult operationResult)
            {
                if (operationResult != OperationResult.Ok && ReportErrors)
                {
                    switch (operationResult)
                    {
                        case OperationResult.CrcError:
                            AddException(new ExtractionFailedException("File is corrupted. Crc check has failed."));
                            break;
                        case OperationResult.DataError:
                            AddException(new ExtractionFailedException("File is corrupted. Data error has occured."));
                            break;
                        case OperationResult.UnsupportedMethod:
                            AddException(new ExtractionFailedException("Unsupported method error has occured."));
                            break;
                        default:
                            AddException(new ExtractionFailedException("An unknown error."));
                            break;
                    }
                }
                else
                {
                    if (_fileStream != null && !_fileIndex.HasValue)
                    {
                        try
                        {
                            _fileStream.BytesWritten -= IntEventArgsHandler;
                            _fileStream.Dispose();
                        }
                        catch (ObjectDisposedException) { }
                        _fileStream = null;
                        GC.Collect();
                        GC.WaitForPendingFinalizers();
                    }
                    var iea = new FileInfoEventArgs(
                        _extractor.ArchiveFileData[_currentIndex], PercentDoneEventArgs.ProducePercentDone(_doneRate));                
                    OnFileExtractionFinished(iea);
                    if (iea.Cancel)
                    {
                        Canceled = true;
                    }
                }
            }
    

      

  • 相关阅读:
    高并发性能测试
    Gitlab源码库里代码提交后,如何触发jenkins自动构建?
    San初步使用
    客户端通过HTTP协议与服务端交换数据
    Web服务端开发需要考虑的问题(续)
    Web服务端开发需要考虑的问题
    我对Web开发的认识
    postgresql远程连接中断的处理
    关于12306的想法
    oracle context
  • 原文地址:https://www.cnblogs.com/-Object/p/5375530.html
Copyright © 2011-2022 走看看