"Windows.System.Launcher"无法启动写字板

5 c# windows-8 windows-runtime windows-store-apps

我正在尝试使用Launcher.LaunchFileAsync()带有示例.txt文件的方法并且它不起作用 - 对于写字板(这是Windows 8上用于显示.txt文件的默认程序)总是返回false.

但是,如果我将控制面板中的.txt处理设置更改为记事本或Word一切正常,则LaunchFileAsync()返回true并正确显示文件.

任何想法为什么会这样?

小智 0

如果您只是想运行桌面应用程序(例如记事本、写字板、Internet Explorer 等),那么请查看 Process 方法和 ProcessStartInfo 类。

try
{
// Start the child process.
    Process p = new Process();
    // Redirect the output stream of the child process.
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.FileName = "C:\Path\To\App.exe";
    p.Start();
}

// Uses the ProcessStartInfo class to start new processes,
// both in a minimized mode.

void OpenWithStartInfo()
{
    ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
    startInfo.WindowStyle = ProcessWindowStyle.Minimized;

    Process.Start(startInfo);

    startInfo.Arguments = "www.northwindtraders.com";

    Process.Start(startInfo);
}
Run Code Online (Sandbox Code Playgroud)