我想从我的UWP应用程序运行一个文件(视频,音乐,图片等(。对于 WPF,我可以使用Process.Start(path)
方法,但此方法现在可用于 UWP。我发现可能我应该使用FullTrustProcessLauncher
(https://learn.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));