如何在 UWP 中启动文件?
How to launch a file in UWP?
我想从我的 appx 的本地状态文件夹启动 xml 文件。我无法使用 var file= ApplicationData.current.LocalFolder.GetFileAsync();
Launcher.LaunchFileAsync(file)
启动文件。有什么方法可以在 UWP 中启动文件吗?
您打开 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
}
请尝试更改默认应用程序以正常加载 xml 文件。
我想从我的 appx 的本地状态文件夹启动 xml 文件。我无法使用 var file= ApplicationData.current.LocalFolder.GetFileAsync();
Launcher.LaunchFileAsync(file)
启动文件。有什么方法可以在 UWP 中启动文件吗?
您打开 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
}
请尝试更改默认应用程序以正常加载 xml 文件。