问题描述
我正在将我的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);
这对于大多数文件都可以正常工作。但是有些文件网址显示System.AggregateException
。
异常详细信息
System.AggregateException:发生一个或多个错误。 (版本号“ 1.1”无效。第1行,位置16。)---> System.Xml.XmlException:版本号“ 1.1”无效。第1行,位置16。 在:0中的System.Xml.XmlTextReaderImpl.Throw(System.Exception e)[0x00027]处 在:0中的System.Xml.XmlTextReaderImpl.Throw(System.String res,System.String arg)[0x00029]处 在:0中的System.Xml.XmlTextReaderImpl.ParseXmlDeclaration(System.Boolean isTextDecl)[0x0061f]处 在:0中的System.Xml.XmlTextReaderImpl.Read()[0x000c6]处 在:0中的System.Xml.Linq.XDocument.Load(System.Xml.XmlReader阅读器,System.Xml.Linq.LoadOptions选项)[0x00016]中 在:0中的System.Xml.Linq.XDocument.Load(System.IO.Stream流,System.Xml.Linq.LoadOptions选项)[0x0000f]处 在:0中的System.Xml.Linq.XDocument.Load(System.IO.Stream流)[0x00000]处 在:0中的VersOne.Epub.Internal.XmlUtils + c__DisplayClass0_0.b__0()[0x00000]中 在System.Threading.Tasks.Task`1 [TResult] .InnerInvoke()[0x0000f]在:0中 在:0中的System.Threading.Tasks.Task.Execute()[0x00000]处 ---从之前引发异常的位置开始的堆栈跟踪---
有此问题的示例文件URL:
我正在使用EpubReader.Cross Nuget来解析epub文件。
为了方便参考,我上传了一个示例project。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)