Capturing console output from a .NET application (C#)

后端 未结 8 2393
臣服心动
臣服心动 2020-11-22 02:20

How do I invoke a console application from my .NET application and capture all the output generated in the console?

(Remember, I don\'t want to save the information

8条回答
  •  粉色の甜心
    2020-11-22 02:53

    From PythonTR - Python Programcıları Derneği, e-kitap, örnek:

    Process p = new Process();   // Create new object
    p.StartInfo.UseShellExecute = false;  // Do not use shell
    p.StartInfo.RedirectStandardOutput = true;   // Redirect output
    p.StartInfo.FileName = "c:\\python26\\python.exe";   // Path of our Python compiler
    p.StartInfo.Arguments = "c:\\python26\\Hello_C_Python.py";   // Path of the .py to be executed
    

提交回复
热议问题