I'm uploading an image from mobile to web using web services..But now i need to save the image to a folder.But i'm getting an exception
"exception in ImageuploadSystem.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at HSC_WCF_MOBILE.HSCMOBILE.UploadFile(String filename, String base64String)
at HSC_WCF_MOBILE.HSCMOBILE.ImageUpload(UploadImage1 objUploadImage)"..Please help me out..Below is my web service Code..
public String ImageUpload(UploadImage1 objUploadImage)
{
string response = string.Empty;
try
{
bl = new BLLayer();
string imageName = objUploadImage.lstObjUploadImage[0].Name;
string imageCode = objUploadImage.lstObjUploadImage[0].Image;
TraceService("Inside method imageupload");
TraceService("imageupload Name:" + imageName);
TraceService("imageupload Image in string format:" + imageCode);
if (objUploadImage.lstObjUploadImage[0].Image != null)
{
string imagesUrl = UploadFile(imageName, imageCode);
TraceService("imageupload Image in URL:" + imagesUrl);
if(imagesUrl != null)
{
response = "success";
}
else
{
response = "failure";
}
}
else
{
response = "failure";
}
}
catch (Exception ex)
{
TraceService("exception in Imageupload" + ex.ToString());
}
finally
{
bl = null;
}
return response;
}
public string UploadFile(string filename,string base64String)
{
byte[] imagebytes = Convert.FromBase64String(base64String);
MemoryStream ms = new MemoryStream(imagebytes, 0, imagebytes.Length);
ms.Write(imagebytes, 0, imagebytes.Length);
Image image = Image.FromStream(ms, true);
string imageUrl = @"E:\HSC_2.0.9_29thJuly2015\HSC\images\Barcodes";
image.Save(imageUrl + filename + ".jpg", ImageFormat.Jpeg);
return imageUrl;
}
Thanks & Regards,
Karthik S