你可以考虑做的是使用Process
类。
var processInfo = new ProcessStartInfo
{
FileName = "consoleapp.exe",
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = false,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardInput = true
};
using (Process clconfigureclient = Process.Start(processInfo))
{
// Write input to your application.
clconfigureclient.StandardInput.WriteLine(value1);
clconfigureclient.StandardInput.WriteLine(value1);
clconfigureclient.WaitForExit();
}
output = cm.StandardOutput.ReadToEnd();
// Do checks on output.