php - C#: Problem running shell commands -


I am trying to run a page to get the PHP parser and then return the result to my server, but when I run through my code command, it does not return anything. I know that the command is right because if I run it manually on the same path then it works fine. Heres my code:

  var p = new process {StartInfo = new ProcessStartInfo ("C: \\ xampp \\ php \\ php.exe", path) {RedirectStandardOutput = true, RedirectStandardError = True, UseShellExecute = false, CreateNoWindow = true}}; Var output = new stringwriter (); Var Error = New String Writer (); P.OutputDataReceived + = (Sender, Args) = & gt; Output.WriteLine (args.Data); P.ErrorDataReceived + = (Sender, Args) = & gt; Error.WriteLine (args.Data); P.Start (); P.BeginOutputReadLine (); P.BeginErrorReadLine (); P.WaitForExit (); If (p.ExitCode! = 0) {new exception throw (string.Format ("PHP failed with the following output: {0} {1}", / * {0} * / environment. NewLine, / * {1 } * / Error.GetStringBuilder (.) ToString ()); } Var res = output.getStringBuilder (). ToString (); Console.WriteLine (race);  

Edit: With this current code, it throws an exception in code with no output.

Set the working directory path

  var p = new process { StartInfo = new ProcessStartInfo ("php", path) {RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, CreateNoWindow = true, working directory = working directory}};  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -