【问题标题】: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 filemimetype 文件有一个长度为 n 的额外字段。 mimetype 文件不允许使用 ZIP 格式的额外字段功能
【发布时间】:2015-11-15 22:58:39
【问题描述】:

我正在使用 C# 库 DotNetZip(Ionic.Zip 和 Ionic.Zlib)从目录生成电子书。目录如下所示:

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

生成存档的代码如下所示:

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();
}

当我通过EPUB Validator 运行它时,它会抛出这个错误:

mimetype 文件有一个长度为 36 的额外字段。mimetype 文件不允许使用 ZIP 格式的额外字段功能。

我没有压缩 mimetype 文件,所以我不知道发生了什么。

【问题讨论】:

    标签: c# zip compression epub


    【解决方案1】:

    https://ebooks.stackexchange.com/questions/6258/the-mimetype-file-has-an-extra-field-of-length-n-the-use-of-the-extra-field-fea

    在从 .epub 文件中删除不需要的 .epub 格式 (META-INF/calibre_bookmarks.txt) 不需要的文件后,我遇到了同样的错误。重新压缩文件后,我收到了上述错误消息。

    使用 -X 参数压缩:

       -X     Do  not save extra file attributes (Extended Attributes on OS/2,
              uid/gid and file times on Unix).
    

    解决了问题。

    【讨论】:

      【解决方案2】:

      可能它与storing dates 有关 - 文档在此功能的描述中提到了“额外字段”。尝试指定EmitTimesInWindowsFormatWhenSaving = false(默认为true),看看它是否能解决您的问题。

      【讨论】:

      • 我所做的一切 - 使用 this query 搜索文档。下次可能对你有用;)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-30
      • 2014-03-05
      • 1970-01-01
      相关资源
      最近更新 更多