I have method like this,
public static void Base64ToImageAndSave(string rawData, string path)
{
string parsedData;
parsedData = rawData.Contains(',')
? rawData.Substring(rawData.IndexOf(',') + 1)
: rawData;
byte[] imageBytes = Convert.FromBase64String(parsedData);
using (MemoryStream memoryStream = new MemoryStream(imageBytes))
{
using (Image image = Image.FromStream(memoryStream))
{
image.Save(path, ImageFormat.Jpeg);
}
}
}
I send base64 parameter for save the picture as a jpeg file. But I have this error
A generic error occurred in GDI+
on this line,
image.Save(path, ImageFormat.Jpeg);
I use using for dispose, but still have error. How can i solve this problem? thanks.