简体   繁体   中英

how to compile c program by asp c#

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?

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();

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();

Please go thorugh this link, it has some information about UseShellExecute property

http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.useshellexecute(v=vs.110).aspx

我认为此链接将为您的问题提供解决方案http://forums.asp.net/t/1828119.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM