update and save of DOCX file results in invalid zip.

Sep 16, 2008 at 8:53 AM
Hello.

I would like to update docx file as zip.
The zip file breaks only in Save().

Is the mistake found in my procedure?

I have not called UpdateItem() yet.

1.5 DotNetZip Library

--- 1:ok ---
using(ZipFile zip = new ZipFile("tmp.zip")){
    zip.AddFile("tmp.xml");
    zip.Save();
}

--- 2:why can not ? ---
string outx = "out.docx";
File.Copy(@"a.docx", outx, true);

using(ZipFile zip = new ZipFile(outx)){
    zip.Save();
}

% unzip -l a.docx
Archive:  a.docx
 Length    Date    Time    Name
 ------    ----    ----    ----
   1312  01-01-80  00:00   [Content_Types].xml
    590  01-01-80  00:00   _rels/.rels
    817  01-01-80  00:00   word/_rels/document.xml.rels
12845554  09-16-08  12:05   word/document.xml
   6990  01-01-80  00:00   word/theme/theme1.xml
    403  01-01-80  00:00   word/_rels/settings.xml.rels
   2788  01-01-80  00:00   word/settings.xml
   1634  01-01-80  00:00   word/fontTable.xml
    764  01-01-80  00:00   docProps/app.xml
  21026  09-03-08  15:15   word/styles.xml
    793  01-01-80  00:00   docProps/core.xml
    260  01-01-80  00:00   word/webSettings.xml
 ------                    -------
12882931                    12

% unzip -l out.docx
Archive:  out.docx
 Length    Date    Time    Name
 ------    ----    ----    ----
   1312  01-01-80  00:00   [Content_Types].xml
error:  expected central file header signature not found (file #1).
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled unzip properly)

Coordinator
Sep 16, 2008 at 8:38 PM
This is a bug!  I've entered workitem 6182 and I've fixed it.   The fix is in the latest v1.6 preview release.
Sep 17, 2008 at 1:51 AM
1.6.1.7 DotNetZip Library:
It looks seem good.
ZipFile#UpdateFiles operated correctly, too.

thanx.