xamarin.forms - Xamarin Forms - Epub:System.AggregateException:发生一个或多个错误
问题描述
我正在将我的 epub 文件 URL 转换为流并保存到本地数据库,如下所示:
Stream stream;
HttpClient client = new HttpClient();
var response = await client.GetAsync(fileUrl);
stream = await response.Content.ReadAsStreamAsync();
epubBook = EpubReader.ReadBook(stream);
//saving to folder
byte[] bytes = await response.Content.ReadAsByteArrayAsync();
string filename = Path.GetFileName(fileUrl);
var folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var filePath = Path.Combine(folderPath, filename);
File.WriteAllBytes(filePath, bytes);
这适用于大多数文件。但一些文件 URL 显示System.AggregateException
.
异常详情
System.AggregateException:发生一个或多个错误。(版本号“1.1”无效。第 1 行,位置 16。)---> System.Xml.XmlException:版本号“1.1”无效。第 1 行,位置 16。在 System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x00027] in <0757e7484a1349cca3b4558c721885b2>:0 在 System.Xml.XmlTextReaderImpl.Throw (System.String res, System.String arg) [0x00029 ] in <0757e7484a1349cca3b4558c721885b2>:0 at System.Xml.XmlTextReaderImpl.ParseXmlDeclaration (System.Boolean isTextDecl) [0x0061f] in <0757e7484a1349cca3b4558c721885b2>:0 at System.Xml.XmlTextReaderImpl.Read () [0x000c6] in <0757e7484a1349cca3b4558c721885b2>:0 at <89374192b20a41739cf7c5bb822846fe> 中的 System.Xml.Linq.XDocument.Load(System.Xml.XmlReader 阅读器,System.Xml.Linq.LoadOptions 选项)[0x00016]:
存在此问题的示例文件 URL:
我正在使用EpubReader.Cross Nuget 来解析 epub 文件。
我已经上传了一个示例项目以方便参考。
解决方案
推荐阅读
- python - 在python中找到一个简化数组的最小和
- javascript - 如何单击父组件中的按钮并访问子组件中的数据?
- css - Show checkbox as if unchecked when printing?
- python-2.7 - Tensorboard callback with keras fit_generator, 'Function' has no attribute 'fetch_callbacks'
- c++ - How do I turn a motor using a digital pin in the setup() function?
- python - 在 R 中运行 TensorFlow 时发现错误的 python 架构
- python - remake window after overrideredirect(True) trouble moving after resizing
- html - Http客户端无法处理css和js
- r - R:有条件地将列表项添加到以前的列表项
- spring - 带有 Postgres ltree 扩展的 Spring JPA