【发布时间】:2018-05-07 05:36:28
【问题描述】:
我正在创建一个 Xamarin Forms 应用程序(目前只有 UWP),我想在其中打开本地存储中的 PDF 文件。在 UWP 项目中,我收到来自 Xamarin 便携式项目的文件路径。我使用以下函数打开 Open With Prompt。
public void OpenFileWith(string path)
{
Task.Run(async () =>
{
var file = await StorageFile.GetFileFromPathAsync(path);
if (file != null)
{
var options = new LauncherOptions();
options.DisplayApplicationPicker = true;
var success = await Launcher.LaunchFileAsync(file, options);
if (success)
{
//File Launched
}
else
{
//File Launch Failed
}
}
});
}
我认为我根据Documentation 所做的一切都是正确的。当我不添加 LauncherOptions 时,文件会在默认选择的应用程序中正确打开。
我有什么遗漏的吗?也许是权限?我知道文档中有一条注释“此属性仅在桌面设备上实现。”。我正在桌面上进行测试(通过 VMWare 的 Windows 10)
【问题讨论】:
标签: c# windows xamarin.forms uwp xamarin.uwp