proc.StandardOutput.ReadToEnd()没有拆分行

时间:2018-05-24 11:49:41

标签: c# cmd

您能否通过运行代码帮助我了解我的错误在哪里? 我期望从C#built app中恢复CMD shell的输出字符串,并且我在一个字符串中获取所有字符串而不分隔行。 我正在运行CLI进行自动化测试。 请参阅附带的代码和图片。 先感谢您。 s string:

Microsoft Windows [Version 10.0.16299.431]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\evgen\source\repos\testim_ex1\testim_ex1\bin\Debug>testim --token "98IQGMuu1jTaBp3HvIMkmsk6tTa2jrS4hUFE247rX9ef0s3FAp" --project "KsfNpLJSbdNlY8czyuwb" --host "ondemand.testim.io" --port 4444 --report-file testim-report.xml --label  "EvgenyShai"
Starting Testim.io CLI
Warning: You are using version 1.16.0, a newer version is available. To update please run npm install (npm install -g @testim/testim-cli)
-----------------------------------------------------------------------
Running Project: KsfNpLJSbdNlY8czyuwb Label: [ 'EvgenyShai' ] Branch: master
-----------------------------------------------------------------------
Batch execution huueFFGwEk was created
Got batch to run:
     1 : Search show in eztv (3gHheApBMO)
-----------------------------------------------------------------------
W:1 Test Search show in eztv started (3gHheApBMO) url: https://app.testim.io/#/project/KsfNpLJSbdNlY8czyuwb/branch/master/test/3gHheApBMO?result-id=2ox8E7Emku
W:1 Get browser Search show in eztv
W:1 Wait for test start
W:1 Wait for test complete
W:1 Test Search show in eztv finished status: PASSED (3gHheApBMO) duration: 0:0:0:17.955
-----------------------------------------------------------------------
Execution completed id: huueFFGwEk Label: [ 'EvgenyShai' ] Duration: 0:0:0:32.945 PASSED: 1 FAILED: 0
-----------------------------------------------------------------------
JUnit XML file saved to testim-report.xml

C:\用户\ evgen \源\回购\ testim_ex1 \ testim_ex1 \ BIN \调试和GT;

private void B_RunTest_Click(object sender, EventArgs e)
{
    ProcessStartInfo psi = new ProcessStartInfo("cmd");
    psi.UseShellExecute = false;
    psi.RedirectStandardOutput = true;
    psi.RedirectStandardError = true;
    psi.CreateNoWindow = true;
    psi.RedirectStandardInput = true;

    var proc = Process.Start(psi);
    t = TB_CLIstring.Text.ToUpper();

    if (t == "CLS")
    {
       proc.StandardInput.WriteLine(TB_CLIstring.Text);
       proc.StandardInput.Flush();
       proc.StandardInput.Close();
       TB_CMD_Output.Text = "";
    }
    else
    {

        proc.StandardInput.WriteLine(TB_CLIstring.Text);
        proc.StandardInput.Flush();
        proc.StandardInput.Close();

        s = proc.StandardError.ReadToEnd() + proc.StandardOutput.ReadToEnd();

        TB_CMD_Output.Text = s;
    }
}

应该如何:

How it should be

它是怎么回事:

How it is

0 个答案:

没有答案