简体   繁体   English

当 DisplayApplicationPicker=true 时 LaunchFileAsync 失败

[英]LaunchFileAsync fails when DisplayApplicationPicker=true

I am new to UWP.我是 UWP 的新手。

I am copying the LaunchFileAsync with DisplayApplicationPicker from the documentation to my project:我正在将带有DisplayApplicationPickerLaunchFileAsync文档复制到我的项目:

        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
        }

The return value is false.返回值为假。

Why?为什么?

BTW, calling LaunchFileAsync(file) (without the options argument) - opens the pdf file in Edge (my default PDF app).顺便说一句,调用LaunchFileAsync(file) (不带options参数)- 在 Edge(我的默认 PDF 应用程序)中打开 pdf 文件。

LaunchFileAsync fails when DisplayApplicationPicker=true当 DisplayApplicationPicker=true 时 LaunchFileAsync 失败

I have tested above code, but we could not reproduce this issue.我已经测试了上面的代码,但是我们无法重现这个问题。 Please check if your pdf is build action is Content and tested the app in the latest OS version(1909).请检查您的 pdf 构建操作是否为Content ,并在最新的操作系统版本 (1909) 中测试了该应用程序。

BTW, calling LaunchFileAsync(file) (without the options argument) - opens the pdf file in Edge (my default PDF app)顺便说一句,调用 LaunchFileAsync(file) (没有选项参数) - 在 Edge 中打开 pdf 文件(我的默认 PDF 应用程序)

Edge is the default app that used to open pdf file. Edge 是用于打开 pdf 文件的默认应用程序。 And you could edit it in Setting page.您可以在设置页面中对其进行编辑。

Setting -> Apps-> Default Apps-> Choose default apps by file type.设置 -> 应用 -> 默认应用 -> 按文件类型选择默认应用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM