Extraction of consoles in richtextbox C# windows form



  • I'm trying to get the console in. RichTextBox♪ Here's my code:

    public void Run()
    {
        Process myProcess = new Process();
        myProcess.StartInfo.FileName = @"start.bat";
        myProcess.StartInfo.CreateNoWindow = true;
        myProcess.StartInfo.UseShellExecute = false;
        myProcess.StartInfo.RedirectStandardOutput = true;
        myProcess.OutputDataReceived += proc_OutputDataReceived;
        myProcess.Start();
        myProcess.BeginOutputReadLine();
    }
    

    public void proc_OutputDataReceived(object sender, DataReceivedEventArgs e)
    {
    this.Invoke(new Action(() =>
    richTextBoxConsole.Text += (e.Data + Environment.NewLine)));
    }

    But... RichTextBox Only the first line from the console. We need to get all the lines in real time. Where's the mistake?



  • There's almost a ready solution in the Mayksoft files.

    https://msdn.microsoft.com/en-us/library/system.diagnostics.process.outputdatareceived.aspx

    Sign on the relevant occasion and just duplicate the text at the event in the field




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2