I am new to UWP.
I am copying the LaunchFileAsync
with DisplayApplicationPicker
from the documentation to my project:
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).