title: Convert music file to byte array c# like matlab
body: <p>I would like to convert any music file into a byte array and print the result in c# just like in MATLAB.</p>
  
  <p>I tried this;</p>
  
  <pre><code>System.IO.FileStream _FileStream = new System.IO.FileStream(_FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
  System.IO.BinaryReader _BinaryReader = new System.IO.BinaryReader(_FileStream);
  
  long _TotalBytes = new System.IO.FileInfo(_FileName).Length;
  _Buffer = _BinaryReader.ReadBytes((Int32)_TotalBytes);
  </code></pre>
  
  <p>And the code to print to console:</p>
  
  <pre><code>Console.WriteLine( byteArrayToString(fileToByteArray("Penguins.jpg")) );
  </code></pre>
  
  <p>where the method's code is:</p>
  
  <pre><code>private static string byteArrayToString(byte[] p)
  {
      string result = System.Text.ASCIIEncoding.ASCII.GetString(p);
      return result;
  }
  </code></pre>
  
  <p>When I run this code, console becomes crazy with irrelevant characters, however I would like to have an array like MATLAB's output.</p>
  
  <p>How should I do that ?</p>
  
  <p>Thanks.</p>