繁体   English   中英

UWP 中的 Process.Start

[英]Process.Start in UWP

我想从我的 UWP 应用程序运行文件(视频、音乐、图片......)。 对于 WPF,我可以使用Process.Start(path)方法,但此方法现在可用于 UWP。 我发现我可能应该使用FullTrustProcessLauncher ( https://docs.microsoft.com/en-us/uwp/api/Windows.ApplicationModel.FullTrustProcessLauncher ),但我不明白它是如何工作的。 有人可以在这里给我写一些非常示例如何使用它或其他什么以及我如何使用这个问题,当我只有一个文件path时? 谢谢你。

我会尝试这样的事情。 这将打开一个 wmv

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

正如 OP 所写,当您只有一个文件路径时,您可以使用以下异步代码。

using Windows.Storage;
using Windows.System;

// ...

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM