Saving zip to more than one stream

Aug 30, 2011 at 9:09 AM

Hi,

I have encountered an error during second call to Save(stream) method. Here is an example:

ZipFile zip = new ZipFile();
// add some files
zip.AddDirectory(@"C:\temp");

// Save to first stream
MemoryStream ms1 = new MemoryStream();
zip.Save(ms1);
ms1.Close();

// Try to save to another stream
MemoryStream ms2 = new MemoryStream();
zip.Save(ms2);
// here exception is thrown
ms2.Close();

The exception is of ZipException type with "Cannot read that as a ZipFile" message and with inner exception of NullReferenceException type with "Object reference not set to an instance of an object." message.

Generaly, I want to check zip size after adding each file. So I save zip to memory stream and check its length. This IMO is more elegant solution than saving to temporary files. Or perhaps, there is another way to check zip size?

Best,

Janusz

Coordinator
Sep 2, 2011 at 2:42 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.