5

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

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

任何想法为什么会这样?

4

1 回答 1

0

如果您只是想运行一个桌面应用程序(如记事本、写字板、Internet Explorer 等),请使用 Process Methods 和 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);
}
于 2013-04-19T07:26:59.397 回答