四联光电智能照明论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3283|回复: 4
打印 上一主题 下一主题

How to print out the value that subprocess prints with C#?

[复制链接]
  • TA的每日心情
    开心
    2018-11-9 08:52
  • 241

    主题

    691

    帖子

    7652

    积分

    论坛元老

    Rank: 8Rank: 8

    积分
    7652
    跳转到指定楼层
    楼主
    发表于 2017-4-13 05:09:08 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
  • TA的每日心情
    开心
    2018-11-9 08:52
  • 241

    主题

    691

    帖子

    7652

    积分

    论坛元老

    Rank: 8Rank: 8

    积分
    7652
    沙发
     楼主| 发表于 2017-4-13 05:10:00 | 显示全部楼层
    // Start the child process.
    Process p = new Process();
    // Redirect the output stream of the child process.
    p.StartInfo.UseShellExecute = false;
    p.StartInfo.RedirectStandardOutput = true;
    p.StartInfo.FileName = "Write500Lines.exe";
    p.Start();
    // Do not wait for the child process to exit before
    // reading to the end of its redirected stream.
    // p.WaitForExit();
    // Read the output stream first and then wait.
    string output = p.StandardOutput.ReadToEnd();
    p.WaitForExit();
  • TA的每日心情
    开心
    2018-11-9 08:52
  • 241

    主题

    691

    帖子

    7652

    积分

    论坛元老

    Rank: 8Rank: 8

    积分
    7652
    板凳
     楼主| 发表于 2017-4-13 05:10:21 | 显示全部楼层
    ProcessStartInfo psi = new ProcessStartInfo("ruby", "/Users/smcho/Desktop/testit.rb");
    psi.RedirectStandardOuput = true;W   
    Process proc = new Process(psi);
    proc.Start();
    StreamReader stdout = proc.StandardOutput;
    string line;
    while ((line = stdout.ReadLine()) != null)
       Console.WriteLine(line);
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|小黑屋|Silian Lighting+ ( 蜀ICP备14004521号-1 )

    GMT+8, 2024-6-1 17:05 , Processed in 1.078125 second(s), 23 queries .

    Powered by Discuz! X3.2

    © 2001-2013 Comsenz Inc.

    快速回复 返回顶部 返回列表