Пример #1
0
        public static async Task Export(Book book)
        {
            await CheckInitialized();

            string  json   = BookToJson(book);
            IFolder folder = await RootDir.CreateFolderAsync(book.Title, CreationCollisionOption.ReplaceExisting);

            foreach (Entry e in book.Entries)
            {
                IFile image = await ImageDir.GetFileAsync(e.ImagePath);

                IFile target = await folder.CreateFileAsync(e.ImagePath, CreationCollisionOption.ReplaceExisting);

                using (var targetStream = await target.OpenAsync(FileAccess.ReadAndWrite))
                    using (var imageStream = await image.OpenAsync(FileAccess.Read))
                        await imageStream.CopyToAsync(targetStream);
            }

            IFile jsonFile = await folder.CreateFileAsync("content.json", CreationCollisionOption.ReplaceExisting);

            await jsonFile.WriteAllTextAsync(json);

            string exportPath = await Zip(folder.Path, book.Title);

            await folder.DeleteAsync();

            AlertManager.ExportPath(exportPath);
        }