Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

UWP LaunchUriAsync failing without error message

$
0
0

I have a UWP app, and I am trying to get it to ask the device to open a pdf in whatever manner it chooses.

The code looks like this:

async static partial void OpenFileWithNativeApp(string filepath)
    {
        Device.BeginInvokeOnMainThread(async () =>
        {
            Uri targetUri = new Uri(filepath);
            bool outcome = await Windows.System.Launcher.LaunchUriAsync(targetUri);
        });
    }

filepath is roughly: {file:///C:/Users/walter.fakename/AppData/Local/Packages/Guid/LocalState/PDFWhatever.pdf} . I can navigate to that place on my c drive, and the pdf is actually there.

When I run this code the outcome that is set by LaunchUriAsync is set to false, indicating that the Uri was not successfully launched. This is correct, as indeed, no other app launches the Uri. But it doesn't tell me how to fix it, such that the Uri would be successfully launched by whatever browser or pdf viewer the device associates with pdfs.

Does anyone see what I'm doing wrong?

-Regards,
Walter


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>