第二个进程后不要清除textBox.Text

时间:2013-08-20 18:47:35

标签: c#

我有一个问题,在第二个进程之后将清除textbox.text,但是如何将其设置为关闭。

(不要清理文本框)

        process1.StartInfo.FileName = ("cmd.exe");
        process1.StartInfo.Arguments = "/C cscript slmgr.vbs /dli | FINDSTR /i \"Name\"";
        process1.StartInfo.UseShellExecute = false;
        process1.StartInfo.RedirectStandardOutput = true;
        process1.StartInfo.RedirectStandardInput = true;
        process1.StartInfo.CreateNoWindow = true;
        process1.Start();
        process1.WaitForExit();
        string sOutput = process1.StandardOutput.ReadToEnd();
        textBox1.Text = sOutput;
        process1.Close();

        process2.StartInfo.FileName = ("cmd.exe");
        process2.StartInfo.Arguments = "/C cscript slmgr.vbs /dli | FINDSTR /i \"License Status\"";
        process2.StartInfo.UseShellExecute = false;
        process2.StartInfo.RedirectStandardOutput = true;
        process2.StartInfo.RedirectStandardInput = true;
        process2.StartInfo.CreateNoWindow = true;
        process2.Start();
        process2.WaitForExit();
        string sOutput1 = process2.StandardOutput.ReadToEnd();
        textBox1.Text = sOutput1;
        process2.Close();

1 个答案:

答案 0 :(得分:3)

您希望将textBox1.Text += sOutput1;用于第二个流程。

+=会将文字追加到最后,而不是完全按照=的方式替换文字。