This project is read-only.

Underlying stream?

Jul 27, 2009 at 11:33 AM


Can I create a zip entry, get the underlying stream, and write to that stream myself? I specifically don't want to have the library "grab from the stream" as described in the FAQ, as it would force me to create an intermediate stream just for that purpose, which is impractical at best. I need to be able to write to the compressed stream incrementally as data gets generated, then flush the stream when I'm done. Is that possible?

Thanks, Axel

Jul 27, 2009 at 3:55 PM
Edited Jul 27, 2009 at 3:58 PM

You can't do what you want with the library, as it is today.

You could use a Pipelined stream, as described in this article.  It would require multiple threads.

Thread 1:

  bs = new BlockingStream();
  while (!done)

Thread 2:

  using (var zip = new ZipFile())
    zip.AddEntry("entryname.txt", "", bs);

I think that should work. And yes, I realize it involves an intermediate stream, which I know is invconvenient. But it provides your desired model.

Jul 27, 2009 at 9:33 PM

Thank you very much for your reply and the suggestion. Do you have any plan to add such streaming abilities in the future?

Jul 27, 2009 at 9:41 PM

I was thinking about how to implement what you asked for, without requiring an external stream to pipeline the information.

So far I haven't imagined a clean design.  I'll keep thinking about it though.  If you like you can make a work item to track this.