Singlem 0 Light Poster

I want to start a external application and capture the output.

private void button1_Click(object sender, EventArgs e)
        {
            Process proc = new Process();
            proc.StartInfo.FileName = "Auto-Compiler.bat";
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.RedirectStandardError = true;
            proc.StartInfo.UseShellExecute = false;
            proc.EnableRaisingEvents = true;
            proc.StartInfo.CreateNoWindow = true;
            proc.ErrorDataReceived += new DataReceivedEventHandler(proc_DataReceived);
            proc.OutputDataReceived += new DataReceivedEventHandler(proc_DataReceived);

            proc.Start();
            proc.BeginErrorReadLine();
            proc.BeginOutputReadLine();
        }

        public void proc_DataReceived(object sender, DataReceivedEventArgs e)
        {
            richTextBox1.AppendText(e.Data);
            richTextBox1.AppendText("/n");
        }

That does not work having a invalidoperationexception any idea how do this. And will this capture the output as the app runs? It is not a bat file will be exe at the end

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.