O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Launching a File

Any app can request that the OS launch a file. Launching a file is achieved using the Windows.System.Launcher class. The following excerpt from the MainPageViewModel retrieves a file stored in the app’s private storage area and launches it using the Launcher’s LaunchFileAsync method:

async Task LaunchFile(){    StorageFolder folder = ApplicationData.Current.LocalFolder;    StorageFile file = await folder.GetFileAsync("Sample.unl");    Launcher.LaunchFileAsync(file);}

The path to the file must exist. If the file does not exist, a FileNotFoundException is raised.

The MainPageViewModel in the WPUnleashed.AppThatLaunchesACustomFileType project saves a sample file with the .unl extension (see Listing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required