public CUMDBook Read(string filepath) { if (!File.Exists(filepath)) { throw new Exception("找不到" + filepath); } this._Book = new CUMDBook(); FileStream input = new FileStream(filepath, FileMode.Open, FileAccess.Read); if (input.CanRead) { BinaryReader reader = new BinaryReader(input); try { this.Read(reader); input.Close(); input = null; try { this._Book.PublishDate = new DateTime(int.Parse(this._Publish_Year), int.Parse(this._Publish_Month), int.Parse(this._Publish_Day)); } catch (Exception) { this._Book.PublishDate = DateTime.Now; } if (this._Book.BookType[1] == 1) { this.ParseChapterTxtContents(); } else if (this._Book.BookType[1] == 2) { this.ParseChapterImages(); } this._Book.BookPath = filepath; return(this._Book); } catch (Exception exception) { Console.WriteLine(exception.Message); Console.WriteLine(exception.StackTrace); this._Book = null; throw exception; } finally { reader.Close(); reader = null; } } throw new Exception("文件正在被使用,无法读取!"); }
public static string WriteUMDBook(CUMDBook book) { UMDBookWriter writer = new UMDBookWriter(book); return(writer.Write()); }
public UMDBookWriter(CUMDBook book) { this._Book = book; }