title: How do I rename a file via batch using Process in c#
body: <p>I have to rename multiple files on my server. For this I make a c# project in visual studio. (side info: this project has to do other stuff too)
  Now I try to call a batch file from that project. This batch file has to rename a file using the old and the new filename.</p>
  
  <p>Here is the code from the batch file:</p>
  
  <pre><code>@echo off
  
  set FILENAME_OLD="%~1"
  set FILENAME_NEW="%~nx2"
  
  ren %FILENAME_OLD% %FILENAME_NEW%
  set error=%errorlevel%
  
  echo %error%
  </code></pre>
  
  <p>This is the code in my c# project:</p>
  
  <pre><code> process.StartInfo.FileName = location;
   process.StartInfo.Arguments = string.Format("\"{0}\" \"{1}\"", oldfilename, newfilename); 
   process.StartInfo.UseShellExecute = false;
   process.StartInfo.RedirectStandardOutput = true;
   process.Start();
   result = process.StandardOutput.ReadLine();
  </code></pre>
  
  <p>As result I always get 1. Which means that "ren" didn't work. What am i doing wrong here?</p>
  
  <p>The filenames are all in a structure like this in my c# project:  @"C:\test\test\test.bat"</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>I came somewhat closer to a solution. The problem was that I cant pass the double quotes as an argument. I need those double quotes as some of my filenames contain spaces. 
  How can I pass those filenames correctly to that batchfile? </p>