2

我有一个问题,在第二个进程之后会将 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();
4

1 回答 1

3

您想改为textBox1.Text += sOutput1;用于第二个过程。

+=会将文本附加到末尾,而不是完全替换文本=

于 2013-08-20T18:55:19.420 回答