Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Windows Phone epub阅读器_C#_.net_Windows Phone 7_Epub - Fatal编程技术网

C# Windows Phone epub阅读器

C# Windows Phone epub阅读器,c#,.net,windows-phone-7,epub,C#,.net,Windows Phone 7,Epub,我正在尝试构建一个wp7应用程序,它必须允许用户阅读epub格式的电子书。因为在windows phone上没有任何可用的库来读取epub文件,所以我正在尝试创建一个。因此,我必须解压缩文件,然后解析它。 问题是我无法解压缩epub文件。我使用的是SharpZipLib.WindowsPhone7.dll,但出现了一个异常: 尝试访问方法失败:System.IO.File.OpenRead(System.String) 在这一行: ZipInputStream s = new ZipInputS

我正在尝试构建一个wp7应用程序,它必须允许用户阅读epub格式的电子书。因为在windows phone上没有任何可用的库来读取epub文件,所以我正在尝试创建一个。因此,我必须解压缩文件,然后解析它。
问题是我无法解压缩epub文件。我使用的是
SharpZipLib.WindowsPhone7.dll
,但出现了一个异常:

尝试访问方法失败:System.IO.File.OpenRead(System.String)

在这一行:

ZipInputStream s = new ZipInputStream(File.OpenRead(path_epubfile));

有人能帮我吗?

这取决于内容是如何获得的。这里有三种可能的选择

选项1:如果使用“内容”的生成操作将内容添加到项目中,则可以使用
StreamResourceInfo
类(在
System.Windows.Resources
命名空间中)获取流

选项2:如果已将其添加到项目中,并将构建操作设置为“嵌入式资源”,则需要使用
GetManifestResourceStream()

注意:您需要将“ProjectName”替换为项目名称。因此,如果您的项目是“EPubReader”,而嵌入的资源是“Example.txt”,则需要将“EPubReader.Example.txt”传递给
GetManifestResourceStream()
。您可以使用
GetManifestResourceNames()
查看哪些资源可用

选项3:如果您在运行时获得了内容,它将存储在
隔离存储中

using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) {
  using (IsolatedStorageFileStream stream = store.OpenFile("MyContent.txt", FileMode.Open)) {
    // Make use of stream as you will
  }
}

什么是路径文件?它是否包含在IsolatedStorage中(即作为内容内置到项目中,或从应用程序中的web下载),还是嵌入到应用程序中?(资源)?目前(为了测试该方法),它已嵌入到我的应用程序中,但它将包含在IsolatedStorage中。
path\u epubfile
的值是多少?path\u epubfile的值是“/lapeste.epub”。谢谢你的帮助!
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ProjectName.MyContent.txt")) {
  // Make use of stream as you will
}
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) {
  using (IsolatedStorageFileStream stream = store.OpenFile("MyContent.txt", FileMode.Open)) {
    // Make use of stream as you will
  }
}