mike Delvotti

mike Delvotti

  • NA
  • 262
  • 0

Converting to byte from picturebox

Dec 7 2013 8:26 AM
Guys, I'm trying to save the image that was entered into my picturebox via open file dialog, but I get the below exception thrown?

'Object reference not set to an instance of an object.'

Below is my save code to save it back to the DB but clearly something is wrong or I'm not converting to byte array correctly?

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

            this.Validate();
            this.companyBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.companyDetailsDataSet);





Answers (1)