title: How to write contents of one file to another file?
body: <p>I need to write contents of a file to another file using File.OpenRead and File.OpenWrite methods. I am unable to figure out how to do it.</p>
  
  <p>How can i modify the following code to work for me.</p>
  
  <pre><code>using (FileStream stream = File.OpenRead("C:\\file1.txt"))
  using (FileStream writeStream = File.OpenWrite("D:\\file2.txt"))
  {
         BinaryReader reader = new BinaryReader(stream);
         BinaryWriter writer = new BinaryWriter(writeStream);
         writer.Write(reader.ReadBytes(stream.Length));
  }
  </code></pre>