内存流中的多个文件位于SevenZipCompressor的一个结果文件中

时间:2018-04-11 14:09:05

标签: c# zip compression sevenzipsharp

This已用于SharpZipLib

对于SevenZipCompressor来说,什么可以是等效的PutNextEntry?

我试过

MemoryStream ms = new MemoryStream(fileByteList.First().Binary);
MemoryStream compressedStream = new MemoryStream(); 
SevenZip.SevenZipCompressor compressor = new SevenZip.SevenZipCompressor();
compressor.DefaultItemName = "toto";
compressor.CompressionMethod = SevenZip.CompressionMethod.Lzma2;
compressor.CompressionLevel = SevenZip.CompressionLevel.Normal;
compressor.CompressStream(ms, compressedStream);


compressor = new SevenZip.SevenZipCompressor();
compressor.CompressionMethod = SevenZip.CompressionMethod.Lzma2;
compressor.CompressionLevel = SevenZip.CompressionLevel.Normal;
compressor.DefaultItemName = "toto2";
MemoryStream ms2 = new MemoryStream(fileByteList[1].Binary); 
compressor.CompressStream(ms2, compressedStream);

MemoryStream ms3 = new MemoryStream();
SevenZip.SevenZipExtractor extractor = new SevenZip.SevenZipExtractor(compressedStream);
extractor.ExtractFile(0, ms3);

给出错误:

An exception of type 'SevenZip.SevenZipArchiveException' occurred in SevenZipSharp.dll but was not handled in user code
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. occurred

0 个答案:

没有答案