title: C# bitmap images, byte arrays and streams!
body: <p>I have a function which extracts a file into a byte array (data).</p>
  
  <pre><code>        int contentLength = postedFile.ContentLength;
          byte[] data = new byte[contentLength];
          postedFile.InputStream.Read(data, 0, contentLength);
  </code></pre>
  
  <p>Later I use this byte array to construct an System.Drawing.Image object
  (where data is the byte array)</p>
  
  <pre><code>       MemoryStream ms = new MemoryStream(data);
         Image bitmap = Image.FromStream(ms);
  </code></pre>
  
  <p>I get the following exception "ArgumentException: Parameter is not valid."</p>
  
  <p>The original posted file contained a 500k jpeg image...</p>
  
  <p>Any ideas why this isnt working?</p>
  
  <p>Note: I assure you I have a valid reason for converting to a byte array and then to a memorystream!!</p>