传递命令行的文本

时间:2010-06-15 16:24:50

标签: c# c++

我需要将一些在richtext框中的文本传递给命令行。这是我的按钮单击甚至是启动cmd。

    private void button1_Click(object sender, EventArgs e)
    {
        ProcessStartInfo psi = new ProcessStartInfo
        {
            FileName = "cmd",
            Arguments = @"/k ""C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat""",
        };
        Process.Start(psi);            
    }

在我的富文本框中包含以下文字。

include iostream

using namespace std;

int main()
{
    cout << "Welcome to the wonderful world of C++!!!\n";

    return 0;
}

任何人都可以提供必要的代码。

1 个答案:

答案 0 :(得分:1)

您将文本框的内容连接到命令行(即作为arguments属性的一部分)

如果您正在尝试编译C ++,则不能这样做。您需要先将其保存为.cpp文件,然后在该文件上调用编译器。