1
Reply

Converting to byte from picturebox

mike Delvotti

mike Delvotti

Dec 7 2013 8:26 AM
870
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)