且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Windows Phone 8推出的PDF阅读器

更新时间:2023-11-21 13:45:34

LaunchUriAsync 不支持在Windows Phone 8%的文档。这将引发称为异常

LaunchUriAsync isn't supported on Windows Phone 8 per the documentation. It throws an exception if called

您可以使用 Windows.System.Launcher.LaunchFileAsync 推出 StorageFile

这代码的工作,例如(assming有一个名为metro.pdf文件项目,以生成操作设置为内容复制到输出目录设置为复制如果较新的)。

This code works for example (assming there's a file called "metro.pdf" in the project, with the Build Action set to Content, with Copy to Output Directory set to Copy if Newer).

var installedLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
var assets = await installedLocation.GetFolderAsync("Assets");
var pdf = await assets.GetFileAsync("metro.pdf");
Windows.System.Launcher.LaunchFileAsync(pdf);