Question

i'm using a syntax check programm, which is called like this in CMD:

"C:\Program Files (x86)\BoLPad\SyntaxCheck\\luac5.1.exe" C:\Users\Andi-PC\Desktop\test\syntax.lua

-> So i call the program and as parameter the file to be checked. Now i'm trying to get the result of the check (so the output in CMD) to my C# Application.

I'm wondering if it's possible, i tried alot even using >command.txt to get the file out of the CMD, but there's nothing in it. So i either need a working output of the text out of CMD or get the CMD text... Any ideas?

Was it helpful?

Solution

You can do it using a process and redirecting the output stream like this:

ProcessStartInfo psi = new ProcessStartInfo(@"C:\Program Files (x86)\BoLPad\SyntaxCheck\luac5.1.exe", @"C:\Users\Andi-PC\Desktop\test\syntax.lua");
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
Process process = Process.Start(psi);
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top