Feb 7, 2014 at 4:32 PM
I'm using DotNetZip in my epub editing program. An epub being a zipped file being an ebook. When I run the epub through the online validator, it says there is an undeclared file, Thumbs.db, in the zipped file. According to File Explorer (Windows 8.1) search, there is no Thumbs.db file anywhere on my drive. I have Show hidden files and folders turned on and still it doesn't show up. Is there any way to exclude that particular file? Here is my code, arrived at through trial and error:
ZipFile zippedBook = new ZipFile(Encoding.UTF8);
zippedBook.CompressionLevel = CompressionLevel.None;
zippedBook.EmitTimesInWindowsFormatWhenSaving = false;
zippedBook.AddEntry("mimetype", "application/epub+zip", Encoding.ASCII);
zippedBook.CompressionLevel = CompressionLevel.Default;
zippedBook.AddDirectory(bookPath + "\\META-INF", "META-INF");
zippedBook.AddDirectory(bookPath + "\\OEBPS", "OEBPS");
zippedBook.Save(booksPath + "\\" + title + ".epub");
VS C# Express 2010. I'm using an older version of DNZ, the newer version wouldn't work with the above code, it complained about Compression level being defined in two places. Is there any simple way to exclude that file? Under OEBPS there's a directory, Images, and that's where the Thumbs.db is.
Feb 7, 2014 at 7:16 PM
Edited Feb 7, 2014 at 7:18 PM
I'd say there's almost certainly a thumbs.db in that folder, mainly because they are devilishly hard to avoid. They appear in any folder that holds images that you've ever viewed in Explorer. Why it's not showing up in a search is a mystery, but unimportant. We just need to get rid of it. Adding
File.Delete(bookPath + "\\OEBPS\\Images\\thumbs.db");
just before the "new ZipFile(...)" should do it. (The file holds that thumbnail images displayed in Explorer in the various "Icon" modes. If it's missing, Explorer will just rebuild it next time it needs it)
Marked as answer by JimGalloway on 2/8/2014 at 8:57 AM
Feb 8, 2014 at 1:48 PM
Edited Feb 8, 2014 at 3:58 PM
Thanks, James. I'm trying to figure out how to delete the thing and doing it in code never occurred to me. Thanks again.
Yup, that did the trick.