Send Ctrl+C to process
I have to se开发者_开发知识库nd to send Ctrl+C to console process created from my C# application. I have found a lot of similar threads but haven't found a solutaion (tried CreateProcess, GenerateConsoleCtrlEvent, etc.). Is there any working example?
The key CRTL + C
is ASCII 3 (in decimal)
myProcess.StartInfo.FileName = "Sort.exe";
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.Start();
StreamWriter myStreamWriter = myProcess.StandardInput;
myStreamWriter.WriteLine(inputText);
Ref: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardinput.aspx
精彩评论