Created
November 4, 2016 07:59
-
-
Save r3ne-pew/4d31036c8ba508ef936ac940f50cc685 to your computer and use it in GitHub Desktop.
Run Python Script in c#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void run_cmd(string cmd, string args) | |
{ | |
ProcessStartInfo start = new ProcessStartInfo(); | |
start.FileName = cmd;//cmd is full path to python.exe | |
start.Arguments = args;//args is path to .py file and any cmd line args | |
start.UseShellExecute = false; | |
start.RedirectStandardOutput = true; | |
using(Process process = Process.Start(start)) | |
{ | |
using(StreamReader reader = process.StandardOutput) | |
{ | |
string result = reader.ReadToEnd(); | |
Console.Write(result); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment