title: C# DataReader issue when used with .AsInputStream() converted stream
body: <p>I need to do various reads on a stream for a decryption process. (for WinRT project) For one, I'd like to do a ReadByte() to get the first byte of the stream. There-after I'd like to read a few bytes into an array, and then read the rest of the bytes into a buffer. </p>
  
  <p>I open up a DataReader on a passed IInputStream object. Which in turn was created from a System.IO.Stream object using the .AsInputStream() method. When I look at the DataReader object during debugging I see that the UnconsumedBufferLength is 0, and I am unable to do ReadByte() or ReadBytes() lest I want to get a <em>"The operation attempted to access data outside the valid range"</em> exception.</p>
  
  <p>Why does the DataReader object seem empty? I've had issues with the AsInputStream() method not returning an actual IInputStream before. How can I ultimately open a DataReader object on a System.IO.Stream object.</p>
  
  <p>Code where the DataReader is assigned:</p>
  
  <pre><code>private Stream DecryptStream(IInputStream streamToDecrypt, byte[] key)
      {
          try
          {
              var dataReader = new DataReader(streamToDecrypt);
  
              int ivLength = dataReader.ReadByte();  //Throws exception (UnconsumedBufferLength = 0 remember)
  
              byte[] iv = new byte[ivLength];
              dataReader.ReadBytes(iv);   //Throws exception (UnconsumedBufferLength = 0 remember)
  
  
              IBuffer toDecryptBuffer = new Windows.Storage.Streams.Buffer(dataReader.UnconsumedBufferLength);
              toDecryptBuffer = dataReader.ReadBuffer(dataReader.UnconsumedBufferLength);   //Works, but only because toDecryptBuffer is of length 0. which is still useless. 
  </code></pre>
  
  <p>Code that calls the above method: </p>
  
  <pre><code>Stream plainStream = DecryptStream(streamToDecrypt.AsInputStream(),key);
  </code></pre>
  
  <p><strong>Update: Code which created the stream</strong>
  This is where the stream is first created, from a System.IO.Compression.ZipArchive object. This is then passed to the interim Decryption funciton as "streamToDecrypt"</p>
  
  <pre><code>ZipArchiveEntry metaEntry = archive.Entries.Where(x =&gt; x.FullName == "myFullNameHere").FirstOrDefault();
  Stream returnStream = metaEntry.Open();
  </code></pre>