如何从系统调用输出到textview

时间:2013-09-19 19:47:15

标签: mono monodevelop

嘿伙计们,我是C#/ Mono编程方面的新手,但我想将系统调用的输出直接发送到textview。我该怎么办?以下是我的目标:

protected void OnButton2Clicked (object sender, EventArgs e)
{
    Application.Init ();
    Window win = new Window ("System Information");
    win.SetDefaultSize (600,400);
    TextView view = new Gtk.TextView ();
    TextBuffer buffer = view.Buffer;

    win.Add (view);
    win.ShowAll ();
    var info = new ProcessStartInfo("dmidecode","-t system"){ RedirectStandardOutput = true, UseShellExecute = false };
    var proc = new Process { StartInfo = info, EnableRaisingEvents = true };
    proc.Start ();
    Console.WriteLine (proc.StandardOutput.ReadToEnd ().ToString());
    buffer.Text = proc.ToString();
}

0 个答案:

没有答案