gpt4 book ai didi

c# - 从 C# 运行 CMD.exe 时系统找不到指定的文件

转载 作者:太空狗 更新时间:2023-10-29 17:33:02 25 4
gpt4 key购买 nike

我在从 C# 控制台程序运行以下代码时收到错误消息。

"The system cannot find the file specified"

代码如下:

System.Diagnostics.Process.Start("C:\Windows\System32\cmd.exe /c");

奇怪的是,当我省略/c 开关时,命令可以运行!?!

知道我做错了什么吗?

最佳答案

Process.Start 将文件名作为参数。将参数作为第二个参数传递:

System.Diagnostics.Process.Start(@"C:\Windows\System32\cmd.exe", "/c");

关于c# - 从 C# 运行 CMD.exe 时系统找不到指定的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2438864/

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