GDI +中发生通用错误的问题.

编程入门 行业动态 更新时间:2024-10-14 02:24:41
本文介绍了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 +中发生通用错误的问题.

本文发布于:2023-10-24 20:27:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524929.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   发生   GDI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!