首页 > 解决方案 > 泛型发生在 GDI+

问题描述

您好我必须在 C# 中保存图片框中包含的图像,为此我使用下面的代码,但会生成此异常:

gdi+ 在 system.drawing.image.save 处发生一般错误

我该如何解决?

C#代码:

 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");
   }
 }

标签: c#exception

解决方案


推荐阅读