0

I am trying to convert a picturebox in byte array

MemoryStream s = new MemoryStream();
picProfilePicture.Image.Save(s, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] pic = s.ToArray();

But when i am using this method i am getting general error in GDI+. How can i fix that?

Dim
  • 433
  • 1
  • 9
  • 23
  • reference the answer(s) in this link https://stackoverflow.com/questions/17352061/fastest-way-to-convert-image-to-byte-array – MethodMan Dec 17 '18 at 21:26

1 Answers1

1
    FileStream fs = new FileStream(selectedFile, FileMode.Open, FileAccess.Read);
    byte[] bimage = new byte[fs.Length];
    fs.Read(bimage, 0, Convert.ToInt32(fs.Length));
Gaurav
  • 623
  • 5
  • 11