Reputation: 754
I am making my college project like codepad.org.
Can anyone help in that how can I compile C and C++ program with C# in ASP.NET?
I have tried this code:
Process proc = new Process();
proc.StartInfo.FileName = "tc.exe";
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
string output = proc.StandardOutput.ReadToEnd();
but it is giving error:
"The Process object must have the UseShellExecute property set to false in order to redirect IO streams."
and there is no method like "UseShellExecute".
Is this the correct way of doing or is there any other method?
Upvotes: 1
Views: 505
Reputation: 13484
use this ProcessStartInfo.UseShellExecute Property
Gets or sets a value indicating whether to use the operating system shell to start the process
proc.StartInfo.UseShellExecute = false;
Process proc = new Process();
proc.StartInfo.FileName = "tc.exe";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
string output = proc.StandardOutput.ReadToEnd();
Upvotes: 2
Reputation: 17532
It's all on MSDN.
ProcessStartInfo.UseShellExecute Property
So you code would just need the UseShellExecute property set to false.
Process proc = new Process();
proc.StartInfo.FileName = "tc.exe";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.Start();
string output = proc.StandardOutput.ReadToEnd();
Upvotes: 2