public void DownloadNovel(NovelInfo novelInfo) { DirectoryInfo di = new DirectoryInfo(SharedData.SavelNovelDirPath); if (!di.Exists) { di.Create(); } FileInfo fi = new FileInfo(di.FullName + @"\" + novelInfo.NCode); string ncode = novelInfo.NCode; bool nType = false; if (novelInfo.NType == NovelType.Serialization) { nType = true; } var novelDownloader = new SyousetukaGetterLib.NovelDownloader(ncode, novelInfo.GeneralAllNo, nType); novelDownloader.DownloadNovel(); List <string> titleList; if (nType) { titleList = novelDownloader.Title[ncode]; } else { titleList = new List <string>(); titleList.Add(""); } var textList = novelDownloader.NovelText[ncode]; novelInfo.Titles = titleList; novelInfo.Texts = textList; int count = titleList.Count < textList.Count ? titleList.Count : textList.Count; using (FileStream fs = new FileStream(fi.FullName, FileMode.Create, FileAccess.Write, FileShare.Read)) { var xmlWriter = new KimamaLib.XMLWrapper.Writer(); xmlWriter.SetRoot("novels"); var attribute = new KimamaLib.XMLWrapper.AttributeInfo() { Name = "count", Value = count.ToString() }; xmlWriter.AddElement("item", attribute); for (int i = 0; i < count; ++i) { var attributes = new KimamaLib.XMLWrapper.AttributeInfo[2] { new KimamaLib.XMLWrapper.AttributeInfo() { Name = "page", Value = (i + 1).ToString() }, new KimamaLib.XMLWrapper.AttributeInfo() { Name = "subtitle", Value = titleList[i] }, }; var text = textList[i].Replace("<ruby>", string.Empty); text = text.Replace("</ruby>", string.Empty); text = text.Replace("<rb>", string.Empty); text = text.Replace("</rb>", string.Empty); text = text.Replace("<rp>", string.Empty); text = text.Replace("</rp>", string.Empty); text = text.Replace("<rt>", string.Empty); text = text.Replace("</rt>", string.Empty); xmlWriter.AddElement("novel", attributes, text); } xmlWriter.Write(fs); } }