title: file IO, is this a bug in Powershell?
body: <p>I have the following code in Powershell</p>
  
  <pre><code>$filePath = "C:\my\programming\Powershell\output.test.txt"
  
  try
  {
      $wStream = new-object IO.FileStream $filePath, [System.IO.FileMode]::Append, [IO.FileAccess]::Write, [IO.FileShare]::Read
  
      $sWriter = New-Object  System.IO.StreamWriter $wStream
  
      $sWriter.writeLine("test")
   }
  </code></pre>
  
  <p>I keep getting error:</p>
  
  <blockquote>
    <p>Cannot convert argument "1", with value: "[IO.FileMode]::Append", for
    "FileStream" to type "System.IO.FileMode": "Cannot convert value
    "[IO.FileMode]::Append" to type "System.IO.FileMode" due to invalid
    enumeration values. Specify one of the following enumeration values
    and try again. The possible enumeration values are "CreateNew, Create,
    Open, OpenOrCreate, Truncate, Append"."</p>
  </blockquote>
  
  <p>I tried the equivalent in C#,</p>
  
  <pre><code>    FileStream fStream = null;
      StreamWriter stWriter = null;
  
      try
      {
          fStream = new FileStream(@"C:\my\programming\Powershell\output.txt", FileMode.Append, FileAccess.Write, FileShare.Read);
          stWriter = new StreamWriter(fStream);
          stWriter.WriteLine("hahha");
      }
  </code></pre>
  
  <p>it works fine!</p>
  
  <p>What's wrong with my powershell script? BTW I am running on powershell </p>
  
  <pre><code>Major  Minor  Build  Revision
  -----  -----  -----  --------
  3      2      0      2237
  </code></pre>