image.save方法未保存图像GDI +错误发生 [英] image.save method is not save image GDI+ error occured
本文介绍了image.save方法未保存图像GDI +错误发生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
string ServerUploadFolder = HttpContext.Current.Server.MapPath("~/Uploads/" + value.PhysicalFileName);
MultipartFormDataStreamProvider streamProvider = new MultipartFormDataStreamProvider(ServerUploadFolder);
Image img = Image.FromFile(ServerUploadFolder);
var bmp = new Bitmap(img.Width, img.Height);
using (Graphics gfx = Graphics.FromImage(bmp))
{
gfx.Clear(Color.White);
gfx.DrawImage(img, 0, 0, img.Width, img.Height);
}
bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
string imagePath = value.FileUrl.Replace(Path.GetFileName(value.FileUrl), Path.GetFileName(value.FileUrl));
bmp.Save(imagePath,img.RawFormat);
在此保存方法中存在问题发生的GDI +错误。
我尝试了很多解决方案但是没有用。
我是90度旋转图像,旋转后保存在数据库中。
In this Save Method There are Problem Occured GDI+ Error . I Have Tried Many Solutions but that is not worked. I am rotate image with 90's degree and after it is rotate it is save in database.
推荐答案
在五种情况下图像文件已经存在于系统驱动器中,因此应用程序会抛出错误GDI +中出现一般错误。
In may case the image file already exists in system drive, so app throws the error "A Generic error occured in GDI+".
- 确认该文件夹必须已存在,才能保存图像。
- 确认该文件必须不存在于同名路径中。
这篇关于image.save方法未保存图像GDI +错误发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文