Compress stream as data written to stream?

Mar 26, 2013 at 8:21 PM
What I want to do is write data to a memory stream (or a StreamWriter), and have that compressed on the fly using 7zip. Something like this (obviously I would want to write more useful data :)
var fs = new FileStream("Test.7z", FileMode.Create);
var ms = new MemoryStream();

var compressor = new SevenZipCompressor();
compressor.CompressionMethod = CompressionMethod.Lzma2;
compressor.CompressionLevel = CompressionLevel.Normal;
compressor.CompressStreamDictionary(new Dictionary<string, Stream> { { "log.txt", ms } }, fs);

for (int i = 0; i < 100; i++)
{
  ms.WriteByte(1);
}
This just seems to create an empty archive; I don't think anything written to the memory stream after calling CompressStreamDictionary is being compressed.

Is this possible?