2

7 zip シャープを使用していますが、暗号化されたアーカイブにファイルを追加しようとすると問題が発生します。暗号化されていないアーカイブへの追加 (適切な方法を使用) は機能しているようですが、暗号化されたアーカイブは次のエラーをスローします。

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");    
}

ありがとう

4

2 に答える 2

0

同じ問題を試してみました:

 compressor.ArchiveFormat = SevenZip.OutArchiveFormat.Zip;

の代わりに:

 compressor.ArchiveFormat = SevenZip.OutArchiveFormat.SevenZip;
于 2015-10-01T13:06:45.637 に答える