FileLauncher 不能像文档显示的那样工作

问题描述 投票:0回答:0

示例代码应该显示选择目标应用程序来启动文件。

文档来自:https://learn.microsoft.com/windows/uwp/launch-resume/launch-the-default-app-for-a-file

        var file = await MyLibrary.UWP.StorageItemPicker.OpenSingleFileAsync(".mp3");
        if (file != null)
        {
            // Set the option to show the picker
            var options = new Windows.System.LauncherOptions();

            options.DisplayApplicationPicker = true;
            //options.LimitPickerToCurrentAppAndAppUriHandlers = true;

            // Launch the retrieved file
            bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
            if (success)
            {
                // File launched
            }
            else
            {
                // File launch failed
            }
        }

但是我的应用程序中的代码无法运行,它没有显示她的选择器 ui,文件也无法启动。

我该如何解决?

uwp
© www.soinside.com 2019 - 2024. All rights reserved.