title: c# How to undo Encoding.UTF8.GetBytes or convert to File.ReadAllBytes
body: <p>C# application was written, to transfer files to FTP server. And function below was used to read jpeg file. This is bad function because it corrupts jpeg : </p>
  
  <pre><code>StreamReader sourceStream = new StreamReader("image.jpeg");
  byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
  </code></pre>
  
  <p>The code below would work for the file transfer.:</p>
  
  <pre><code> fileContents = File.ReadAllBytes(sourceStream.ReadToEnd());
  </code></pre>
  
  <p>And now i have library of corrupted jpegs. </p>
  
  <p>How to fix the mess?</p>