“A generic error occurred in GDI+” when attempting to use Image.Save

后端 未结 6 1049
挽巷
挽巷 2020-12-11 06:21

I am developing an Outlook 2010 Add-In, and am loading an image from a serialized XML file. The image loads fine, and am able to assign it to a pictureBox object on a Winfo

6条回答
  •  情书的邮戳
    2020-12-11 07:08

    I too faced same error for code line:

    wmImg.Save(BrandImgPath,ImageFormat.Png);
    
    BrandImgPath = "D:/XYZ/fileName;
    

    Found cause:

    XYZ folder didn't exist in D: drive. So my code was creating this folder later. One should ensure if that path exist or not.

    if (Directory.Exists(@"D:/XYZ")) return;
    

    Hope it will help someone to solve his code mistakes.

提交回复
热议问题