I'm writing a wrapper class for a command line executable. This exe accepts input from stdin until i hit ctrl+c in the command prompt shell, in which case it prints output based on the input to stdout. I want to simulate that ctrl+c press in c# code, sending the kill command to a .Net process object. I've tried calling Process.kill(), but that doesn't seem to give me anything in the process's StandardOutput StreamReader. Might there be anything I'm not doing right? Here's the code I'm trying to use:
ProcessStartInfo info = new ProcessStartInfo(exe, args);
info.RedirectStandardError = true;
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
Process p = Process.Start(info);
p.StandardInput.AutoFlush = true;
p.StandardInput.WriteLine(scriptcode);
p.Kill();
string error = p.StandardError.ReadToEnd();
if (!String.IsNullOrEmpty(error))
{
throw new Exception(error);
}
string output = p.StandardOutput.ReadToEnd();
however output is always empty even though I get data back from stdout when I run the exe manually. edit: this is c# 2.0 btw