Compressing and Decompressing Streams

Apr 1, 2009 at 5:33 PM
Edited Apr 1, 2009 at 6:02 PM
I can't see a method in SevenZipExtractor simmetric to SevenZipCompressor.CompressStream. Is there a workaround? Maybe a SevenZipStream with simmilar functionality to DeflateStream?


P.S. : Just found SevenZip.SevenZipExtractor.ExtractFile(int, Stream)... will try it.

Apr 1, 2009 at 10:42 PM
Look at public static void SevenZipExtractor.DecompressStream
Apr 2, 2009 at 8:54 PM
I am using your library to Compress Serialized DataSets. I tried the static methods SevenZip.SevenZipCompressor.CompressStream and SevenZip.SevenZipExtractor.DecompressStream but the compression only wrote the first 18 bytes to the output stream 9I can send you my sample if you are interested). Then I found the byte-oriented static methods SevenZip.SevenZipCompressor.CompressBytes and SevenZip.SevenZipExtractor.ExtractBytes and these ones worked fine. The original byte size was 327,328, using System.IO.Compression.DeflateStream went down to 275,979 and finally, using your library I got  55,660 ... but it took 10 times longer :-(



Apr 3, 2009 at 7:35 PM
Edited Apr 3, 2009 at 7:36 PM
Sorry, I didn't explain properly.

If you use SevenZipCompressor.CompressStream() static method, the stream is compressed with the managed LZMA sdk code. To decompress it, you use SevenZipExtractor.DecompressStream (also static; managed).

If you use (new SevenZipCompressor()).CompressStream() method, the stream is compressed by the external native 7-zip dll and not only in 7-zip format (you specify it). To decompress it, you use (new SevenZipExtractor(Stream compressedStream)).ExtractFile(index = 0, Stream output).