Problem with Update a zip from stream

Nov 28, 2014 at 5:05 PM
Edited Nov 28, 2014 at 5:06 PM
Hi there,

I wanted to update a zip with the following code :
FileStream input = new FileStream(destination, FileMode.Open, FileAccess.ReadWrite);
//destination is the string with the path to the zip

using (ZipFile z = ZipFile.Read(input))
         {
             z.UpdateItem(@"C:\Data\test.odt");
             z.Save();
         }
The problem is that the save-method overwrites the original zip. I tried replacing save() with save(outputStream) and save(destination), but both times the zip to update is overwritten. Do you have any suggestions how I can make this work.

thanks in advance

Madome31
Nov 30, 2014 at 6:34 AM
Hi,

I figured out the Problem, I just changed the code to this :

           FileStream input = new FileStream(destination, FileMode.Open, FileAccess.ReadWrite);
           //destination is the string with the path to the zip
            using (ZipFile z = ZipFile.Read(input))
            {
                z.AddFile(@"C:\Data\test.odt");
                z.Save(destination);
            }
I hope it helps.

Madome