title: vb.net How to pass a string with spaces to the command line
body: <p>I am trying to call an external program using Process:</p>
  
  <pre><code>    Dim strExe As String = "E:\Projects\Common Files\mktorrent.exe"
      Dim p As New Process
      Dim pinfo As New ProcessStartInfo
      pinfo.UseShellExecute = False
      pinfo.RedirectStandardOutput = True
      pinfo.Arguments = " -a http://blah.com/announce.php -l " &amp; FileSizeMarker &amp; " " &amp; fn
      pinfo.FileName = strExe
      pinfo.WorkingDirectory = fn.Substring(0, fn.LastIndexOf("\"))
      pinfo.WindowStyle = ProcessWindowStyle.Normal
      pinfo.CreateNoWindow = True
      p.StartInfo = pinfo
      p.Start()
  </code></pre>
  
  <p>The problem is with the filename (variable fn above).  If it has spaces, the command chokes - without spaces, it works fine.  I have tried adding 1, 2 or3 quotes, like this:</p>
  
  <pre><code>    fn = Chr(34) &amp; Chr(34) &amp; Chr(34) &amp; fn &amp; Chr(34) &amp; Chr(34) &amp; Chr(34)
  </code></pre>
  
  <p>and also</p>
  
  <pre><code>    fn = "\") &amp; Chr(34) &amp; fn &amp; "\"&amp; Chr(34)
  </code></pre>
  
  <p>and many other combinations, but it still gives me an error.  Any thoughts on how I can get this to work?
  TIA</p>