public static Book LoadBook(string path) { Book book; book = new Book() { Name = Path.GetFileName(path), FilePath = path, Pages = new List<Page>() }; SevenZipExtractor.SetLibraryPath(@"C:\Program Files (x86)\7-Zip\7z.dll"); using (var zip = new SevenZipExtractor(path)) { foreach (var file in zip.ArchiveFileData) { try { var s = new MemoryStream(); zip.ExtractFile(file.FileName, s); Image image = new Bitmap(s); var page = new Page(); page.Name = file.FileName; page.Display = image; book.Pages.Add(page); } catch (Exception e) { } } } book.Pages = book.Pages.OrderBy(p => p.Name).ToList(); return book; }
public static Series LoadSeries(string path) { var dir = new DirectoryInfo(path); var series = new Series { Name = dir.Name, Books = new List<Book>() }; foreach (var file in dir.GetFilesByExtensions(".cbr", ".cbz", ".zip", ".rar")) { var book = new Book {Name = Path.GetFileName(file.Name)}; if (book != null) series.Books.Add(book); } return series; }