title: launch gnuplot from c#, change directory and load multiple gnuplot scripts
body: <p>I want to generate a couple of hundreds .txt scripts in a C# app, launch GnuPlot  and generate .png graphs for each of the scripts I have. </p>
  
  <p>I can launch GnuPlot from C# with the following code:</p>
  
  <pre><code>Process gnuPlotProcess = new Process();
  gnuPlotProcess.StartInfo = new ProcessStartInfo(@"C:\Program Files\gnuplot\bin\wgnuplot.exe");
  gnuPlotProcess.Start();
  </code></pre>
  
  <p>The first problem appears when I'm trying to change the current directory, adding this line of code before starting the process:</p>
  
  <pre><code>gnuPlotProcess.StartInfo.Arguments = "cd '" + scriptsPath + "'";
  </code></pre>
  
  <p>Now GnuPlot doesn't start.</p>
  
  <p>The second problem, which I was able to test working on GnuPlot's default current directory, is when attempting to pass the "load 'script_xxx.txt'" command. Here is the complete code (inspiration from <a href="https://stackoverflow.com/questions/13390244/plotting-graph-from-gunplot-in-c-sharp">Plotting graph from Gunplot in C#</a>):</p>
  
  <pre><code>Process gnuPlotProcess = new Process();
  gnuPlotProcess.StartInfo = new ProcessStartInfo(@"C:\Program Files\gnuplot\bin\wgnuplot.exe");
  gnuPlotProcess.StartInfo.RedirectStandardInput = true;
  gnuPlotProcess.StartInfo.UseShellExecute = false;
  theProcess.Start();
  StreamWriter sw = gnuPlotProcess.StandardInput;
  sw.WriteLine("load '" + pathToScript + "'");
  sw.Flush();
  </code></pre>
  
  <p>The script that is found on pathToScript should create a .png file, and it works when being launched directly from gnuPlot. But from code, nothing happens.</p>
  
  <p>Any help would be appreciated.</p>