Search code examples
c#zipcompressionepub

The mimetype file has an extra field of length n. The use of the extra field feature of the ZIP format is not permitted for the mimetype file


I am using the C# library DotNetZip (Ionic.Zip and Ionic.Zlib) to generate an ebook from a directory. Directory looks like this:

BookName
|
|___content/
|       images/
|       css/
|       (html pages, .ops, .ncx)
|
|___META-INF/
|       container.xml
|
|___mimetype

The code to generate the archive looks like this:

using (ZipFile zip = new ZipFile(pathTemp + ".epub"))
{
    zip.RemoveSelectedEntries("*.*");
    zip.AddFile(mimetype, "").CompressionLevel = CompressionLevel.None;
    zip.AddDirectory(pathTemp + "\\content", "content");
    zip.AddDirectory(pathTemp + "\\META-INF", "META-INF");
    zip.Save();
}

When I run it through the EPUB Validator, it throws this error:

The mimetype file has an extra field of length 36. The use of the extra field feature of the ZIP format is not permitted for the mimetype file.

I'm not compressing the mimetype file, so I don't know what is happening.


Solution

  • Probably it has something to do with storing dates - the docs mention "extra field" in the description of this feature. Try specifying EmitTimesInWindowsFormatWhenSaving = false (its true by default) and see if it resolves your issue.