public bool ExportCompressFile(Comic comic, string originalPath) { try { string path = originalPath + comic.Title; this.CreateFolder(path); // create comic folder foreach (var chapter in comic.Chapters) { this.CreateFolder(path + @"\" + chapter.Title); // create chapter folder foreach (var page in chapter.Pages) { CopyFiles(page.ImgPath, path + @"\" + chapter.Title + @"\" + page.PageIndex + ".jpg"); } } ConvertJson(comic, path); // convert meta data file and save to comic folder if (!Directory.Exists(originalPath)) { Directory.CreateDirectory(originalPath); } FileStream fsOut = File.Create(originalPath + @"\" + comic.Title + ".magatana"); ZipOutputStream zipStream = new ZipOutputStream(fsOut); CompressFolder(path, zipStream, 1); zipStream.IsStreamOwner = true; zipStream.Close(); return true; } catch (Exception) { return false; } }
private void ConvertJson(Comic comic, string path) { var serializeObject = Newtonsoft.Json.JsonConvert.SerializeObject(comic); File.WriteAllText(path + @"\meta.manga", serializeObject); }