title: Run an FTP commands batch file from C#
body: <p>I have written a winform app in C# which modifies FTP commands in a script file (server address etc..) and then executes a batch file that is supposed to start FTP from command prompt and download files according to script.</p>
  
  <p>When i run the Batch file external to app (from command prompt or double click), the files are being downloaded fine, but when executing the batch from the app nothing happens...</p>
  
  <p>I also noticed following difference:
  When running batch externally I see "<strong>ftp></strong> open 10.1.1.1" in cmd window.
  When running batch from the app I see "open 10.1.1.1" in cmd window,(missing the "ftp>").</p>
  
  <p>My guess is that I'm not using System.Diagnostics.Process() correctly...</p>
  
  <p>C# relevant part:</p>
  
  <pre><code>    private void button1_Click(object sender, EventArgs e)
      {
              var cmd = new System.Diagnostics.Process();
              cmd.StartInfo.FileName = "runFTP.bat";
              cmd.StartInfo.UseShellExecute = false;
              cmd.StartInfo.RedirectStandardInput = true;
              cmd.StartInfo.WorkingDirectory = path;
              cmd.Start();
              cmd.WaitForExit();
              cmd.Close();
          }
  
      }
  </code></pre>
  
  <p>Batch file (runFTP.bat):</p>
  
  <pre><code>echo off
  
  @echo Downloading files...
  REM ==Start FTP with script==
  
  ftp -i -s:ftpCmd.txt
  
  del ftpCmd.txt
  
  @echo Done!
  @echo Exiting...
  </code></pre>
  
  <p>FTP script file (ftpCmd.txt):</p>
  
  <pre><code>open 10.1.1.1
  user
  password
  bin
  cd /rootFolder/new
  lcd C:\Downloads
  mget *.*
  bye
  </code></pre>