gpt4 book ai didi

c# - "Windows.System.Launcher"不启动写字板

转载 作者:太空狗 更新时间:2023-10-29 23:51:52 27 4
gpt4 key购买 nike

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

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

知道为什么会这样吗?

最佳答案

如果您只是想运行一个桌面应用程序,例如(记事本、写字板、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);
}

关于c# - "Windows.System.Launcher"不启动写字板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14403014/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com