title: File to Byte Array in WinJS
body: <p>I'm tinkering with some Windows Store development in JavaScript and I seem to be stuck on how to get a byte array from a binary file.  I've found a couple of examples online, but they all seem to only read in text whereas my file is an image.  I'm opening the file like this:</p>
  
  <pre><code>Windows.Storage.FileIO.readBufferAsync(photos[currentIndex]).done(function (buffer) {
  
      var dataReader = Windows.Storage.Streams.DataReader.fromBuffer(buffer);
      var fileContent = dataReader.readString(buffer.length);
      dataReader.close();
  
      // do something with fileContent
  
  });
  </code></pre>
  
  <p>Where <code>photos[currentIndex]</code> is a file (loaded from <code>getFilesAsync()</code>).  The error in this case, of course, is that <code>readString</code> fails on binary data.  It can't map the "characters" into a string.  I also tried this:</p>
  
  <pre><code>Windows.Storage.FileIO.readBufferAsync(photos[currentIndex]).done(function (buffer) {
  
      var bytes = [];
      var dataReader = Windows.Storage.Streams.DataReader.fromBuffer(buffer);
      dataReader.readBytes(bytes);
      dataReader.close();
  
      // do something with bytes
  
  });
  </code></pre>
  
  <p>But <code>bytes</code> is empty, so I think I'm using this incorrectly.  I imagine I'm just overlooking something simple here, but for some reason I just can't seem to find the right way to read a binary file into a byte array.  Can somebody offer a second set of eyes to help?</p>