title: How can you use Console.Out to write a byte[] to a file?
body: <p>In java you can do this:</p>
  
  <pre><code>File file = new File(filepath);
  PrintStream pstream = new PrintStream(new FileOutputStream(file));
  System.setOut(pstream);
  
  byte[] bytes = GetBytes();
  System.out.write(bytes);
  </code></pre>
  
  <p>I want to do something similar in C#. I tried this but it didn't work:</p>
  
  <pre><code>StreamWriter writer = new StreamWriter(filepath);
  Console.SetOut(writer);
  
  byte[] bytes = GetBytes();
  Console.Out.Write(bytes);
  </code></pre>
  
  <p>It looks like the main problem here is that the Write method does not accept an array of bytes as an argument.</p>
  
  <p>I know that I could get away with File.WriteAllBytes(filepath, bytes), but I would like to keep the C# code as close as possible to the original, java code.</p>