title: How to redirect stdout of a C# project to file using the Visual Studio "command line arguments" option
body: <p>I am trying to redirect the output of a C# program to a file. When using "cmd.exe" I can simply run it with <code>myprogram.exe arg1 arg2 &gt; out.txt</code>, but I'd like to accomplish the same thing using Visual Studio <em>Start Options</em>.</p>
  
  <p>I created a <em>C# Empty Project</em> and added this code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>using System;
  class Test
  {
      public static void Main(string[] args)
      {
          foreach (var arg in args) Console.WriteLine(arg);
      }
  }
  </code></pre>
  
  <p>Then I edited the <em>command line arguments</em> in the Project Settings:
  <img src="https://i.stack.imgur.com/dEA1M.png" alt="Project Properties"></p>
  
  <p>Running the project with <em>Ctrl+F5</em> does not work as intended. I get the command line arguments printed in the console and not in the output file:</p>
  
  <pre><code>arg1
  arg2
  &gt;
  output.txt
  </code></pre>
  
  <p>If I change the command line arguments to: <code>arg1 arg2 "&gt; output.txt"</code> I get the following output:</p>
  
  <pre><code>arg1
  arg2
  ^&gt; output.txt
  </code></pre>
  
  <p>I noticed that an empty <code>output.txt</code> file gets created in the Output folder.</p>
  
  <p>Is this thing possible to accomplish or am I forced to keep using cmd.exe to launch my program?</p>