日期:2014-05-19  浏览次数:20398 次

改变图象大小后保存,出现GDI+中发生一般性错误
HttpPostedFile   file   =   fileupbmp.PostedFile;
                  string   imageurl   =   Server.MapPath( "../images/TreeImage/ "   +         fileupbmp.FileName);

                  file.SaveAs(imageurl);
                  System.Drawing.Image   imgOutput   =   System.Drawing.Bitmap.FromFile(imageurl);
                  System.Drawing.Image   imgOutput2   =   imgOutput.GetThumbnailImage(18,   18,   null,   IntPtr.Zero);
                  imgOutput2.Save(imageurl);//出现“GDI+中发生一般性错误”
                  imgBmp.ImageUrl   =   "../images/TreeImage/ "   +   fileupbmp.FileName;
                  imgOutput.Dispose();
                  imgOutput2.Dispose();

------解决方案--------------------
imgOutput2.save前,先把imgOutput释放了,资源占用了
------解决方案--------------------
imgOutput2.Save(imageurl);//出现“GDI+中发生一般性错误”

images/TreeImage/

这是由于你的 images/TreeImage/ 文件夹没有写入的权限造成的。
你给这个文件夹加上 everyone 的完全控制权限。(很不安全哦,哈哈)