0

我是 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 文件。

4

1 回答 1

0

当 DisplayApplicationPicker=true 时 LaunchFileAsync 失败

我已经测试了上面的代码,但我们无法重现这个问题。请检查您的 pdf 是否是构建操作,Content并在最新的操作系统版本 (1909) 中测试了该应用程序。

顺便说一句,调用 LaunchFileAsync(file) (不带选项参数) - 在 Edge 中打开 pdf 文件(我的默认 PDF 应用程序)

Edge 是用于打开 pdf 文件的默认应用程序。您可以在设置页面中对其进行编辑。

设置 -> 应用程序-> 默认应用程序-> 按文件类型选择默认应用程序。

于 2020-02-13T09:06:13.840 回答