如何用asp c#编译c程序

时间:2014-03-21 06:37:53

标签: c# asp.net

我正在制作像codepad.org这样的大学项目。

任何人都可以帮忙,我如何在ASP.NET中用C#编译C和C ++程序?

我试过这段代码:

        Process proc = new Process();
        proc.StartInfo.FileName = "tc.exe";
        proc.StartInfo.RedirectStandardOutput = true;
        proc.Start();
        string output = proc.StandardOutput.ReadToEnd();

但它给出了错误:

"The Process object must have the UseShellExecute property set to false in order to redirect IO streams."

并且没有类似" UseShellExecute"。

的方法

这是正确的做法还是有其他方法?

5 个答案:

答案 0 :(得分:2)

全部都在MSDN上。

ProcessStartInfo.UseShellExecute Property

因此,您只需要将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();

答案 1 :(得分:2)

使用此ProcessStartInfo.UseShellExecute Property

  

获取或设置一个值,该值指示是否使用操作系统shell启动进程

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

答案 2 :(得分:1)

请浏览此链接,它包含有关UseShellExecute属性的一些信息

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

答案 3 :(得分:1)

我认为这个链接可以为您的问题http://forums.asp.net/t/1828119.aspx

提供解决方案

答案 4 :(得分:0)

相关问题