 <p>You're trying to assign an array of bytes (<code>byte[]</code>) to a single byte, hence the error.</p> <p>Try the following code:</p> <pre><code>byte[] imgarray = new byte[imglength]; </code></pre>