如何在 UWP 中启动文件?

Vis*_*u s 5 windows-store-apps win-universal-app

我想从我的 appx 的本地状态文件夹启动 xml 文件。我无法使用 启动文件var file= ApplicationData.current.LocalFolder.GetFileAsync(); Launcher.LaunchFileAsync(file)。有没有办法在 UWP 中启动文件?

Nic*_*SFT 6

您打开 xml 文件的默认选项似乎存在一些问题。我尝试使用以下代码启动一个 xml 文件。而且效果很好。我用来打开 xml 文件的默认应用程序是 Microsoft Edge。

string xmlFile = @"TextFile.xml";

var file = await ApplicationData.Current.LocalFolder.GetFileAsync(xmlFile);

if (file != null)
 {

     var success = await Launcher.LaunchFileAsync(file);

     if (success)
     {
         // File launched
     }
     else
     {
         // File launch failed
     }
 }
 else
 {
     // Could not find file
 }
Run Code Online (Sandbox Code Playgroud)

请尝试更改默认应用程序以正常加载 xml 文件。