Generics gdi+;将img保存到“我的图片”时出错

Generics gdi+;将img保存到“我的图片”时出错,generics,gdi+,bmp,system.drawing.imaging,Generics,Gdi+,Bmp,System.drawing.imaging,我想创建一个程序,将bmp文件保存到my pictures\test。 由于一些未知的原因,我得到-“GDI+中发生了一个通用错误。” 请帮助我理解为什么这会发生在我身上。 我的代码是: System.Drawing.Image img = Properties.Resources.pic; string path = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures); string p

我想创建一个程序,将bmp文件保存到my pictures\test。 由于一些未知的原因,我得到-“GDI+中发生了一个通用错误。” 请帮助我理解为什么这会发生在我身上。 我的代码是:

System.Drawing.Image img = Properties.Resources.pic;
        string path = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
        string path2 = path+@"\"+"test";
        img.Save(path2, System.Drawing.Imaging.ImageFormat.Bmp);

可以是任意数量的内容,但请尝试保存图像的副本:

System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(Properties.Resources.pic);
string path = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
string path2 = path+@"\"+"test";
bmp.Save(path2);