As Nickolay points out, the 'deflate' method is being used instead of 'store'. It was a real pain for me to find out how to fix this, and for anyone else who finds this topic, I used the ZipStorer class by Jaime Olivares to add the mimetype using 'store'.
https://github.com/jaime-olivares/zipstorer
It's easy to add this code to a C# project (it's not a DLL), and it's easy to add files using 'store' instead of 'deflate'. Here's my code for doing that:
Dictionary<string, string> FilesToZip = new Dictionary<string, string>()
{
{ ConfigPath + @"mimetype", @"mimetype"},
{ ConfigPath + @"container.xml", @"META-INF/container.xml" },
{ OutputFolder + Name.Output_OPF_Name, @"OEBPS/" + Name.Output_OPF_Name},
{ OutputFolder + Name.Output_XHTML_Name, @"OEBPS/" + Name.Output_XHTML_Name},
{ ConfigPath + @"style.css", @"OEBPS/style.css"},
{ OutputFolder + Name.Output_NCX_Name, @"OEBPS/" + Name.Output_NCX_Name}
};
using (ZipStorer EPUB = ZipStorer.Create(OutputFolder + "book.epub", ""))
{
bool First = true;
foreach (KeyValuePair<string, string> File in FilesToZip)
{
if (First) { EPUB.AddFile(ZipStorer.Compression.Store, File.Key, File.Value, ""); First = false; }
else EPUB.AddFile(ZipStorer.Compression.Deflate, File.Key, File.Value, "");
}
}
This code creates a perfectly valid EPUB file. However, if you don't need to worry about validation, it seems most eReaders will accept an EPUB with a 'deflate' mimetype. So my previous code using .NET's ZipArchive produced EPUBs that worked in Adobe Digital Editions and a PocketBook. For example:
/*using (ZipArchive EPUB = ZipFile.Open(OutputFolder + Name.Output_EPUB_Name, ZipArchiveMode.Create))
{
foreach (KeyValuePair<string, string> AddFile in AddFiles)
{
if (AddFile.Key.Contains("mimetype"))
{
EPUB.CreateEntryFromFile(AddFile.Key, AddFile.Value, CompressionLevel.NoCompression);
}
else EPUB.CreateEntryFromFile(AddFile.Key, AddFile.Value, CompressionLevel.Optimal);
}
}*/