C# bitmap images, byte arrays and streams!

后端 未结 5 719
醉梦人生
醉梦人生 2021-01-25 17:12

I have a function which extracts a file into a byte array (data).

        int contentLength = postedFile.ContentLength;
        byte[] data = new byte[contentLen         


        
5条回答
  •  忘了有多久
    2021-01-25 17:26

    You're not checking the return value of postedFile.InputStream.Read. It is not at all guaranteed to fill the array on the first call. That will leave a corrupt JPEG in data (0's instead of file content).

提交回复
热议问题