Hello I have to save an image contained in a picturebox in C #, to do so I use the code below, but this exception is generated:
a generic error occurred in gdi+ at system.drawing.image.save
how can I solve them?
C# Code:
using (MemoryStream m = new MemoryStream())
{
if (pictureBoxFirma.Image != null)
{
const int milliseconds = 2000;
Thread.Sleep(milliseconds);
pictureBoxFirma.Image.Save(m, ImageFormat.Jpeg);
byte[] photo_aray = new byte[m.Length];
m.Position = 0;
m.Read(photo_aray, 0, photo_aray.Length);
utemp.AggionraFirmaUtente(photo_aray, IdUtente);
}
else
{
Console.WriteLine("Errore: inserimento immagine non riuscito");
}
}