Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your question is a little confusing but I think i see your problem. First you should check out this blog post to see <a href="http://csharptest.net/?p=321" rel="noreferrer">common issues with System.Diagnostics.Process</a>. Your code happens to violate one that isn't listed there. The reuse of the Process object itself.</p> <p>You need to refactor the code like:</p> <pre><code> class MyProcessStarter { private ProcessStartInfo _startInfo = new ProcessStartInfo(); public MyProcessStarter(string exe, string workingDir) { _startInfo.WorkingDirectory = workingDir; _startInfo.FileName = exe; _startInfo.UseShellExecute = false; _startInfo.RedirectStandardOutput = true; } public string Run(string arguments) { _startInfo.Arguments = arguments; Process p = Process.Start(_startInfo); p.Start(); string strOutput = p.StandardOutput.ReadToEnd(); p.WaitForExit(); return strOutput; } } </code></pre> <p>I've written a more complete and accurate implementation called <a href="http://code.google.com/p/csharptest-net/source/browse/#svn/trunk/src/Library/Processes" rel="noreferrer">ProcessRunner</a>. The following demonstrates it's usage to perform the same operation:</p> <pre><code>using CSharpTest.Net.Processes; partial class Program { static int Main(string[] args) { ProcessRunner run = new ProcessRunner("svn.exe"); run.OutputReceived += new ProcessOutputEventHandler(run_OutputReceived); return run.Run("update", "C:\\MyProject"); } static void run_OutputReceived(object sender, ProcessOutputEventArgs args) { Console.WriteLine("{0}: {1}", args.Error ? "Error" : "Output", args.Data); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload