首页 新闻 会员 周边

保存图片提示System.Drawing.Image.Save 方法而导致 GDI+ 中发生一般性错误 的发生

0
[已解决问题] 解决于 2011-06-14 13:08

 Image imgPhoto = Image.FromFile(ImgFile);
            Bitmap bmPhoto = new Bitmap(CutWidth, CutHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            Graphics gbmPhoto = Graphics.FromImage(bmPhoto);
            gbmPhoto.DrawImage(imgPhoto, new Rectangle(0, 0, CutWidth, CutHeight), PointX * imgPhoto.Width / PicWidth, PointY * imgPhoto.Height / PicHeight, CutWidth * imgPhoto.Width / PicWidth, CutHeight * imgPhoto.Height / PicHeight, GraphicsUnit.Pixel);
            gbmPhoto.Dispose();


             if (!Directory.Exists(HttpContext.Current.Server.MapPath("/DZ/User/UserImages")))
            {
                Directory.CreateDirectory(HttpContext.Current.Server.MapPath("/DZ/User/UserImages"));
            }
                bmPhoto.Save(HttpContext.Current.Server.MapPath("/DZ/User/UserImages/"), System.Drawing.Imaging.ImageFormat.Jpeg);
                imgPhoto.Dispose();
                gbmPhoto.Dispose();
                bmPhoto.Dispose();

           System.Drawing.Image.Save 方法而导致 GDI+ 中发生一般性错误 的发生,请各位打侠帮我看下,那代码出问题了

rains的主页 rains | 小虾三级 | 园豆:860
提问于:2011-06-13 16:16
< >
分享
最佳答案
0

HttpContext.Current.Server.MapPath("/DZ/User/UserImages/imgname.jpg")

慧☆星 | 大侠五级 |园豆:5640 | 2011-06-14 10:08
其他回答(1)
0

这是一个目录,你需要提供一个文件名来保存。

bmPhoto.Save(HttpContext.Current.Server.MapPath("/DZ/User/UserImages/"), System.Drawing.Imaging.ImageFormat.Jpeg);

冠军 | 园豆:886 (小虾三级) | 2011-06-14 08:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册