【发布时间】:2014-08-20 13:05:46
【问题描述】:
我正在尝试在 Windows Phone 8.1 的 C# 中使用这个库。
http://epubreader.codeplex.com/
根据初始化行中的文档,我们必须传递文件的路径。
Epub epub = new Epub(@"c:\example.epub");
我使用文件选择器选择文件,并通过了
file.path
作为参数。但在运行时会引发 System.IO.FileNotFoundException。
如何将路径传递给库?
编辑
文件选择器代码 -
private void file_clicked(object sender, RoutedEventArgs e)
{
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.Desktop;
openPicker.FileTypeFilter.Add(".epub");
openPicker.PickSingleFileAndContinue();
}
编辑 将文件复制到应用本地文件夹
public async void ContinueFileOpenPicker(FileOpenPickerContinuationEventArgs args)
{
if (args.Files.Count > 0)
{
var file = args.Files[0];
Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
StorageFile sampleFile;
await file.CopyAsync(localFolder, file.Name, NameCollisionOption.ReplaceExisting);
sampleFile = await localFolder.GetFileAsync(file.Name);
Epub epub = new Epub(sampleFile.Path); //exception occurs in this line
}
}
【问题讨论】:
-
嗯,你能发布你的文件选择器代码吗?
-
@MatDev8 我已经添加了文件选择器代码。请看一下。
-
我认为stackoverflow.com/questions/25011016/… 是一个很好的解决方案。
标签: c# windows-phone-8 windows-runtime windows-phone-8.1