asp.net : A generic error occurred in GDI+

后端 未结 2 1915
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-15 14:44

I create an asp.net 4.0 web application which has a web service for uploading images. I am uploading images by sending the image in form of Base64 string from my mobile app

2条回答
  •  一个人的身影
    2020-12-15 15:14

    Furthermore I think it's worth pointing out that when MemoryStream is used, stream must always be closed and save method MUST be called before the stream closure

     byte[] byteBuffer = Convert.FromBase64String(Base64String);
     MemoryStream memoryStream = new MemoryStream(byteBuffer);
     memoryStream.Position = 0;
     Bitmap bmpReturn = (Bitmap)Bitmap.FromStream(memoryStream);
     bmpReturn.Save(PicPath, ImageFormat.Jpeg);
     memoryStream.Close();
    

提交回复
热议问题