Launching an App for a File
The following code shows how to launch the default app for viewing PNG files using Launcher
’s LaunchFileAsync
method:
async Task LaunchOtherApp() { StorageFile file = await Package.Current.InstalledLocation.GetFileAsync( @"Assets\Logo.scale-100.png"); if (file != null) { // Launch the default image viewer bool success = await Launcher.LaunchFileAsync(file); if (!success) { ... } } }
This code uses a handy API accessible via Windows.ApplicationModel.Package
that provides access to files packaged with your app.
Get Universal Windows® Apps with XAML and C# Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.