【问题标题】:SevenZipSharp append an encrypted archiveSevenZipSharp 附加加密存档
【发布时间】:2012-07-04 12:50:36
【问题描述】:

我正在使用 7 个 zip sharp,但在尝试将文件添加到加密存档时遇到问题。 附加到非加密存档(使用适当的方法)似乎有效,但加密存档会引发以下错误

Invalid archive: open/read error! Is it encrypted and a wrong password was provided?
If your archive is an exotic one, it is possible that SevenZipSharp has no signature 
for its format and thus decided it is TAR by mistake. Message: Can not update the archive:
Open() failed.

我想知道是否有其他人成功执行了此操作 这是我正在使用的一些示例代码

void AppendEncFilefile(Stream docstream, string addfilename, string archivename)
{          

    SevenZip.SevenZipCompressor compressor = new SevenZip.SevenZipCompressor();
    compressor.CompressionMode = SevenZip.CompressionMode.Append;
    compressor.CompressionLevel = SevenZip.CompressionLevel.Ultra;
    compressor.ArchiveFormat = SevenZip.OutArchiveFormat.SevenZip;
    compressor.EncryptHeaders = true;

    //this fails : trying to pass archive and file to add
    compressor.CompressFilesEncrypted(datafile, "password", addfilename);
    //this fails : trying to pass stream containg data to be written, and filename to save as
    compressor.CompressStreamDictionary(
          new Dictionary<string, System.IO.Stream>() 
              { 
                 { addfilename, xmldocstream } 
              }
          , archivename, "password");    
}

谢谢

【问题讨论】:

    标签: append archive 7zip encryption sevenzipsharp


    【解决方案1】:

    我也有同样的问题。我通过在不加密的情况下进行压缩来“解决”这个问题,但添加了一个带加密的 +1 文件。 7z 文件管理器要求输入密码,7z 包含所有文件——这对我来说已经足够了。当然,文件管理器列出了其余未加密的文件。

    仍在寻找解决此问题的 GOOD 方法,但对于解决方法,它只是暂时解决问题。

    【讨论】:

      【解决方案2】:

      有同样的问题尝试:

       compressor.ArchiveFormat = SevenZip.OutArchiveFormat.Zip;
      

      代替:

       compressor.ArchiveFormat = SevenZip.OutArchiveFormat.SevenZip;
      

      【讨论】:

      • 欣赏答案,但是由于更好的压缩,我专门寻找 7zip
      猜你喜欢
      • 2012-08-17
      • 2013-06-24
      • 2018-08-20
      • 2019-10-26
      • 2011-10-15
      • 2017-08-09
      • 1970-01-01
      • 2011-06-16
      • 1970-01-01
      相关资源
      最近更新 更多