当前位置: 代码迷 >> ASP.NET >> 改变图象大小后保存,出现GDI+中发生一般性异常
  详细解决方案

改变图象大小后保存,出现GDI+中发生一般性异常

热度:10429   发布时间:2013-02-25 00:00:00.0
改变图象大小后保存,出现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 的完全控制权限。(很不安全哦,哈哈)


  相关解决方案