[英]Process.Start in UWP
I want to run a file (video, music, picture..) from my UWP application.我想从我的 UWP 应用程序运行文件(视频、音乐、图片......)。 For WPF I can use
Process.Start(path)
method, but this method is now available for UWP.对于 WPF,我可以使用
Process.Start(path)
方法,但此方法现在可用于 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.我发现我可能应该使用
FullTrustProcessLauncher
( https://docs.microsoft.com/en-us/uwp/api/Windows.ApplicationModel.FullTrustProcessLauncher ),但我不明白它是如何工作的。 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?有人可以在这里给我写一些非常示例如何使用它或其他什么以及我如何使用这个问题,当我只有一个文件
path
时? Thank you.谢谢你。
I would try something like this.我会尝试这样的事情。 This will open a wmv
这将打开一个 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.正如 OP 所写,当您只有一个文件路径时,您可以使用以下异步代码。
using Windows.Storage;
using Windows.System;
// ...
await Launcher.LaunchFileAsync(await StorageFile.GetFileFromPathAsync(path));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.