tags:

views:

73

answers:

1

Hi, I need to pass some text which is in richtext box to command line. This is my Button click even which start the 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);            
    }

In my rich text box contain following text.

include iostream

using namespace std;

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

    return 0;
}

Can anyone provide me necessary codes.

+1  A: 

You concatenate the contents of your textbox to the commandline (i.e. as part of the arguments property)

If you're trying to compile C++ though, you can't do that. You'll need to save it as a .cpp file first and then invoke the compiler on that file.

Billy ONeal
Can you please show me how to pass the file name with "cl" command according to my given example
Kasun
@Kansun: I don't know how to do that. I've never used the "cl" command line tool. You will need to pass the input filename as an argument, however. The exact format of that argument however is dependent on the cl.exe program.
Billy ONeal