GDI +中发生通用错误的问题. [英] problem with A generic error occurred in GDI+.

查看:118
本文介绍了GDI +中发生通用错误的问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
当我想从fileupload保存图像时出现问题.
我的代码是:

hi all
when i want save image from fileupload Face with problem .
my code is :

string filename = "nopic.gif";


       if (FileUpload1.HasFile)
       {


               filename = FileUpload1.FileName;

               Bitmap bmp = new Bitmap(FileUpload1.FileContent);
               System.Drawing.Image img = bmp;

               ResizeImage.ImageResize imgRe = new ResizeImage.ImageResize();
               img = imgRe.Resize(img, 85, 113);




               //string directory = Server.MapPath(@"~\admin\teacherPic\\");
               string directory = Server.MapPath("./all_images/foroshgahImages/");
               img.Save(directory + filename);

       }



提示:此代码在其他位置运行.在此位置,我的网页上包含一个updatePanel.



hint: this code run Other places.In this location my webPage content a updatePanel.

推荐答案

问题所在行:img.save(目录+文件名) ;"

在这种情况下,我会怀疑问题出在上面的那一行:
"problem in line:img.save(directory+filename);"

In which case, I would suspect the problem is either the line above:
string directory = Server.MapPath("./all_images/foroshgahImages/");

可能返回无效路径,或者目录写权限设置不正确.保存文件之前,请检查directory值.

通过将其包含在try/catch中,可以查看并查看是否在异常和内部异常中获得了任何有用的信息,这可能有助于将其隔离.

Which may be returning an invalid path, or that the directory write permissions are not set correctly. Check the directory value before you save the file.

Look and see if you get any useful information in the exception and inner exception by enclosing it in a try / catch - that may help isolate it.


我发现了我的错误
错误是这样的:
I find my error
error is this :
Bitmap bmp = new Bitmap(FileUpload1.FileContent);
                System.Drawing.Image img = bmp;
 
                ResizeImage.ImageResize imgRe = new ResizeImage.ImageResize();
                img = imgRe.Resize(img, 85, 113);


现在如何调整图片大小


now how resize my image


这篇关于GDI +中发生通用错误的问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆