【发布时间】:2018-11-07 04:46:38
【问题描述】:
我正在做一个需要 cmd 来运行应用程序的项目。
自动填充应用程序的文本框。
目前,我已经看到了这段代码,但这不起作用。
它抛出这个异常 - StandardIn has not been redirected
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = @"C:\Windows\System32\cmd.exe";
process.StartInfo = startInfo;
process.StandardInput.WriteLine(@"C:\Program Files\WinMerge\WinMergeU.exe" + txtJOB.Text + txtKJOB.Text + "- minimize - noninteractive - noprefs - cfg Settings / DirViewExpandSubdirs = 1 - cfg ReportFiles / ReportType = 2 - cfg ReportFiles / IncludeFileCmpReport = 1 - r - u -or" + txtResultPath.Text);
process.Start();
如果我使用 cmd 并运行这一行
"C:\Program Files\WinMerge\WinMergeU.exe" + txtJOB.Text + txtKJOB.Text + "- minimize - noninteractive - noprefs - cfg Settings / DirViewExpandSubdirs = 1 - cfg ReportFiles / ReportType = 2 - cfg ReportFiles / IncludeFileCmpReport = 1 - r - u -or" + txtResultPath.Text
这确实有效。但是我将如何在 C# 中实现这个命令行呢?
有人可以帮我解决这个问题吗?
提前致谢。
【问题讨论】:
-
@mjwills。先生?这是控制台上显示的唯一消息。
Exception thrown: 'System.InvalidOperationException' in System.dll StandardIn has not been redirected.