i want to pass param to another exe file which is also developed by c#. i know how to pass parameter to exe file from my application. this way i can pass param to exe file
Process p= new Process();
p.StartInfo.FileName = "demo.exe";
p.StartInfo.Arguments = "param1 param2";
p.Start();
p.WaitForExit();
now demo.exe file will do some job and will return some data. i want to capture that data at my end. so guide what i alter in my code to capture response return by demo.exe file. help me with altered code. thanks
probably below solution may solve my issue. i will test it. When you create your Process object set StartInfo appropriately:
var proc = new Process {
StartInfo = new ProcessStartInfo {
FileName = "program.exe",
Arguments = "command line arguments to your executable",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
then start the process and read from it:
proc.Start();
while (!proc.StandardOutput.EndOfStream) {
string line = proc.StandardOutput.ReadLine();
// do something with line
}