I am using DotNetZip (http://dotnetzip.codeplex.com/) to build Zip files on the fly. I would like to be able to create a ZIP file in code and then add it to another ZIP file in code. Will this work? My code is below. I am trying to use a MemoryStream to hold the internal zip file and then add that memory stream to the main zip file. I'm not sure if this is correct. When I try this, my internal zip file has zero bytes and it fails when I try to open up the resulting main zip file.
using (ZipFile _mainZip = new ZipFile())
{
using (ZipFile _internalZip = new ZipFile())
{
..add stuff to the internal zip..
MemoryStream _myMemoryStream = new MemoryStream();
_internalZip.Save(_myMemoryStream);
_mainZip.AddEntry("myTitle.zip", _myMemoryStream);
}
}
_mainZip.Save("myZip.zip");
It might be that the MemoryStream's position is at the end of the stream.
You could try to set it to the begining:
_myMemoryStream.Position = 0;
That might work.