Hi,
I am working on C# windows applications.Wh at i want to do is, I want to Redirect the output from Command Prompt to the Rich Text Box, Actually i am unable to read the entire output of the comman prompt, but i can see only the few lines.I don't know what's the wrong in my code.Here is the sample code.
ChildLaunch()
{
Process p = new Process();
p.StartInfo.Wor kingDirectory = RootDir;
p.StartInfo.Fil eName = Environment.Get EnvironmentVari able("COMSPEC") ;
p.StartInfo.Arg uments = "/c" + " " + CommandLine.Tri m();
p.OutputDataRec eived += new DataReceivedEve ntHandler(p_Out putDataReceived );
p.StartInfo.Red irectStandardOu tput = true;
p.StartInfo.Red irectStandardIn put = true;
p.StartInfo.Red irectStandardEr ror = true;
p.StartInfo.Cre ateNoWindow = true;
p.StartInfo.Use ShellExecute = false;
p.EnableRaising Events = true;
p.Start();
p.BeginOutputRe adLine();
}
void p_OutputDataRec eived(object sender, DataReceivedEve ntArgs e)
{
richTextBox1.Ap pendText(e.Data );
}
Here RootDir is the working directory which we have to set in the command prompt. CommandLine is the String which i used in my code to collect all the elements from the GUI.
Using my code I can read only some amount of output.. But i need to read the entire output. Can any one help me?
I am working on C# windows applications.Wh at i want to do is, I want to Redirect the output from Command Prompt to the Rich Text Box, Actually i am unable to read the entire output of the comman prompt, but i can see only the few lines.I don't know what's the wrong in my code.Here is the sample code.
ChildLaunch()
{
Process p = new Process();
p.StartInfo.Wor kingDirectory = RootDir;
p.StartInfo.Fil eName = Environment.Get EnvironmentVari able("COMSPEC") ;
p.StartInfo.Arg uments = "/c" + " " + CommandLine.Tri m();
p.OutputDataRec eived += new DataReceivedEve ntHandler(p_Out putDataReceived );
p.StartInfo.Red irectStandardOu tput = true;
p.StartInfo.Red irectStandardIn put = true;
p.StartInfo.Red irectStandardEr ror = true;
p.StartInfo.Cre ateNoWindow = true;
p.StartInfo.Use ShellExecute = false;
p.EnableRaising Events = true;
p.Start();
p.BeginOutputRe adLine();
}
void p_OutputDataRec eived(object sender, DataReceivedEve ntArgs e)
{
richTextBox1.Ap pendText(e.Data );
}
Here RootDir is the working directory which we have to set in the command prompt. CommandLine is the String which i used in my code to collect all the elements from the GUI.
Using my code I can read only some amount of output.. But i need to read the entire output. Can any one help me?
Comment