title: Writing File using System.IO.BinaryWriter
body: <p>I am trying to write an audio file using C#'s <a href="http://msdn.microsoft.com/en-us/library/system.io.binarywriter.aspx" rel="nofollow noreferrer"><code>System.IO.BinaryWriter</code> class</a>.</p>
  
  <p>It works fine when I perform this action:</p>
  
  <pre><code>File.WriteAllBytes(@"C:\TestFile\File1", br.ReadBytes((int)br.BaseStream.Length));
  </code></pre>
  
  <p>However it does not work when I do the following:</p>
  
  <pre><code>Encoding e = Encoding.ASCII;
  char[] reslts = e.GetChars(br.ReadBytes((int)br.BaseStream.Length));
  br.BaseStream.Position = 0;
  File.WriteAllBytes((@"C:\TestFile\File2",e.GetBytes(reslts));
  </code></pre>
  
  <p>I checked out the byte arrays, in both cases the array contained the same values ( I copied their value into a separate excel file and checked to see if there are any differences, there are none).</p>
  
  <p>In both cases the base stream position is set to 0.</p>
  
  <p>The code itself works, the file is created successfully. The problem occurs when I open the file, the first file works fine, the second file is not recognized by Windows Media Player.</p>
  
  <p>Does anyone have any ideas of what I could be doing wrong?</p>