C# MAC OS中使用.NET内核的Process.Start出现错误-没有这样的文件或目录
我正在创建一个.NET核心控制台应用程序来运行命令C# MAC OS中使用.NET内核的Process.Start出现错误-没有这样的文件或目录,c#,macos,.net-core,C#,Macos,.net Core,我正在创建一个.NET核心控制台应用程序来运行命令 public bool RunCommand() { try { var procStartInfo = new ProcessStartInfo("exec", "cal") { RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow =
public bool RunCommand()
{
try
{
var procStartInfo = new ProcessStartInfo("exec", "cal")
{
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = false
};
var proc = new Process { StartInfo = procStartInfo };
proc.Start();
// Get the output into a string
output = proc.StandardOutput.ReadToEnd();
return proc.ExitCode == decimal.Zero ? true : false;
}
finally
{
// do something
}
}
我得到以下错误-
Unhandled Exception: System.ComponentModel.Win32Exception: No such file or directory
at System.Diagnostics.Process.ResolvePath(String filename)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at HockeyApp.Enablers.IosCodeSign.ProcessManager.RunCommand(String command, String& output)
at HockeyApp.Enablers.IosCodeSign.Program.Main(String[] args)
我甚至试过像-
var procStartInfo = new ProcessStartInfo("cal")
不走运
我遗漏了什么?我只是删除了构造函数中的
“exec”
,在输出之前放置一个var
,代码也可以工作,Calc是一个Windows程序。OSX虽然有“计算器”,但实际上是“cal”。我的打字错误。我刚刚编辑了这个问题。在任何情况下,其not working.exec都是bash shell命令,而不是程序。查看/usr/local/bin