GDI +中发生一般错误的问题。(problem with A generic error occurred in GDI+.)
IT问题网 2021-01-20 00:00:00
问 题
嗨所有
当我想从fileupload中保存图像时遇到问题。
我的代码是:
string filename = " nopic.gif"跨度>;
if (fileupload1.hasfile)
{
filename = fileupload1.filename;
位图bmp = new 位图(fileupload1.filecontent);
system.drawing.image img = bmp;
resizeimage.imageresize imgre = new resizeimage.imageresize();
img = imgre.resize(img, 85 , 113 );
// string directory = server .mappath(@"\\\ minmin \ teacherpic \\");
string directory = server.mappath(" ./ all_images / foroshgahimages /");
img.save(目录+文件名);
}
提示:此代码运行其他地方。在此位置我的网页内容updatepanel。
解决方案
"行中的问题:img.save(目录+文件名);"
在这种情况下,我怀疑问题是上面的一行:
string directory = server.mappath(" ./ all_images / foroshgahimages /");可能返回无效路径,或者未正确设置目录写入权限。在保存文件之前检查目录值。
查看您是否获得了有用的信息。异常和内部异常通过将其封闭在try / catch中 - 这可能有助于隔离它。
我发现我的错误
错误是这样的:
位图bmp = new 位图(fileupload1.filecontent);
system.drawing.image img = bmp;
resizeimage.imageresize imgre = new resizeimage.imageresize();
img = imgre.resize(img, 85 , 113 );
现在如何调整我的图像大小
分享:
热门推荐