I am trying to run avrdude
in C# application in visual studio 2010 and taking its output in a RichTextox.
Here is my code:-
void proc_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
if (e.Data != null)
{
string newLine = e.Data.Trim() + Environment.NewLine;
MethodInvoker append = () => txtOutput.Text += newLine;
txtOutput.BeginInvoke(append);
}
}
private void btnAVRDUSR_Click(object sender, EventArgs e)
{
string command = "/c avrdude";
ProcessStartInfo procStartInfo = new ProcessStartInfo("CMD", command);
Process proc = new Process();
proc.StartInfo = procStartInfo;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
procStartInfo.CreateNoWindow = true;
procStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
proc.OutputDataReceived += new DataReceivedEventHandler(proc_OutputDataReceived);
proc.Start();
proc.BeginOutputReadLine();
procStartInfo.CreateNoWindow = true;
procStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
}
This, code doesn't show any thing in RichTextBox
. Now I decide to use pin command. So, I replace this line
string command = "/c avrdude ";
by this
string command = "/c ping 192.168.1.1";
This time my code woks great. So, can any one tell me why my avrdude
is not working in this code.