c# - 当 DisplayApplicationPicker=true 时 LaunchFileAsync 失败
问题描述
我是 UWP 的新手。
我正在将文档中的 with 复制到我LaunchFileAsync
的项目中:DisplayApplicationPicker
string imageFile = @"test.pdf";
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);
if (file != null)
{
// Set the option to show the picker
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true;
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
if (success)
{
// File launched
}
else
{
// File launch failed ====> GETTING TO HERE
}
}
else
{
// Could not find file
}
返回值为假。
为什么?
顺便说一句,调用LaunchFileAsync(file)
(不带options
参数)- 在 Edge(我的默认 PDF 应用程序)中打开 pdf 文件。
解决方案
当 DisplayApplicationPicker=true 时 LaunchFileAsync 失败
我已经测试了上面的代码,但我们无法重现这个问题。请检查您的 pdf 是否是构建操作,Content
并在最新的操作系统版本 (1909) 中测试了该应用程序。
顺便说一句,调用 LaunchFileAsync(file) (不带选项参数) - 在 Edge 中打开 pdf 文件(我的默认 PDF 应用程序)
Edge 是用于打开 pdf 文件的默认应用程序。您可以在设置页面中对其进行编辑。
设置 -> 应用程序-> 默认应用程序-> 按文件类型选择默认应用程序。
推荐阅读
- sqlite - 在 Github 操作上的内存数据库上运行 PDO SQLite 查询
- angular - AngularFire - Firebase Auth 显示错误
- c++ - 有没有办法根据模板变量调用成员对象的不同函数
- java - 否则无法将三元条件 Java 运算符转换为普通运算符
- php - 如何在不使用注释的情况下为自定义 DTO 操作配置标识符?
- pagespeed - PageSpeed Insights 超时
- python - 为 django 添加下拉列表
- python - Python 我想无限期地重复一个函数
- batch-file - 检查进程是否关闭/未运行,然后重新启动应用程序
- python - 用 Python 编写一个 Discord 机器人 - 处理一个重复用户刚才所说的内容并在其间使用表情符号的命令,无法弄清楚