capture output from cammad line argument

  • Thread starter Thread starter Guest
  • Start date Start date
hi Jon
v r doing a editor in C# for compilation of c c++ and java.Simply open the
file and execute it...
here is the code
//////////////////////////starting the execution
here//////////////////////////
private void Execute_Click(object sender, System.EventArgs e)
{
try
{
Process chk = new Process();
string str_txtbx= txtbxCmd.Text;//compilation command
string str_txtbx1= txtbxPath.Text;//Path of the file to be
executed
if(str_txtbx1=="")
chk.StartInfo.FileName=str_txtbx;
else
{
chk.StartInfo.Arguments=str_txtbx1 ;
chk.StartInfo.FileName=str_txtbx;
}
MessageBox.Show("ERR TRy->"+ str_txtbx1 );

chk.StartInfo.UseShellExecute = false;
chk.StartInfo.RedirectStandardOutput = true;
chk.Start();
chk.WaitForExit();

string output = chk.StandardOutput.ReadToEnd();
MessageBox.Show(output);//

}
catch (Exception e1)
{
MessageBox.Show("ERR ->" + e1.ToString());
}
}

//////////////end///////////////////////////////////////
But here from StandardOutput Stream we r not able to read.But process is
executing fine.
Actually after the execution the output of the program v have to display in
the form. How can this possible?
Expecting ur reply.............
lkr
 
Back
Top