Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process.Start in UWP

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://learn.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.

like image 415
Banana Cake Avatar asked Sep 07 '25 13:09

Banana Cake


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);
like image 151
Ken Tucker Avatar answered Sep 09 '25 05:09

Ken Tucker


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));
like image 38
Nerpson Avatar answered Sep 09 '25 04:09

Nerpson