Process.Start in UWP

Viewed 1917

I want to run a file (video, music, picture..) from my UWP application. For WPF I can use Process.Start(path) method, but this method is now available for UWP. I found that probably I should use FullTrustProcessLauncher (https://docs.microsoft.com/en-us/uwp/api/Windows.ApplicationModel.FullTrustProcessLauncher), but I don't get how does it work. Can someone write me here some very example how to use it or what else and how can I use for this problem, when I have only a path of the file? Thank you.

2 Answers

I would try something like this. This will open a wmv

 Windows.System.LauncherOptions options = new Windows.System.LauncherOptions();
 options.ContentType = "video/x-ms-wmv";
 Windows.System.Launcher.LaunchUriAsync(new Uri(fileUrl), options);

As the OP wrote, when you only have a file path, you can use the following asynchronous code.

using Windows.Storage;
using Windows.System;

// ...

await Launcher.LaunchFileAsync(await StorageFile.GetFileFromPathAsync(path));
Related