The outputBox.Text is NOT getting double the lines, the Text file is getting every line of output double. The output is correct everything is working fine, but its writing everything twice in my log file. Can anybody see why? Thanks.
Here is the code:
Heres an example of the output:
Here is the code:
Code:
private void outPut() { Process process = new Process(); process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.FileName = "gsengine.exe"; process.OutputDataReceived += new DataReceivedEventHandler(process_OutputDataReceived); process.Start(); process.BeginOutputReadLine(); } delegate void AddTextCallback(string text); void process_OutputDataReceived(object sender, DataReceivedEventArgs e) { this.AddText(e.Data); } private void AddText(string text) { string path = "Log.txt"; using (StreamWriter sw = File.AppendText(path)) { sw.Write(DateTime.Now + text + Environment.NewLine); sw.Close(); } if (this.outputBox.InvokeRequired) { AddTextCallback d = new AddTextCallback(AddText); this.Invoke(d, new object[] { text }); } else { this.outputBox.Text += text + Environment.NewLine; outputBox.SelectionStart = outputBox.Text.Length; outputBox.ScrollToCaret(); } }
Code:
2/8/2008 9:13:34 PMº º 2/8/2008 9:13:34 PMº º 2/8/2008 9:13:34 PMÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼCredits: 2/8/2008 9:13:34 PMÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼCredits: 2/8/2008 9:13:34 PM - Prodian - Startup/settings interface 2/8/2008 9:13:34 PM - Prodian - Startup/settings interface 2/8/2008 9:13:34 PM 2/8/2008 9:13:34 PM
Comment