Vaibhav Singh

Vaibhav Singh

  • NA
  • 132
  • 22.8k

Save System.Drawing.Image File to your Local Computer

Jan 27 2019 7:56 AM
Lets say that I have fetched an Image called img from my Database and Now I want to save it in my Local.
I am getting below Error for same.
<pre>Solving: A generic error occurred in GDI+. in C#</pre>
Is there anyone who had faced this kind of stuff and was able to save the image finally in local ?
Below is the code
<pre>public static void SavePic(Image img)
{
Image result = null;
ImageFormat format = ImageFormat.Png;
result = img;
using (Image imageToExport = result)
{
string filePath = string.Format(@"C:\Vaibhav Personal.{0}", format.ToString());
imageToExport.Save(filePath, format);
}
}</pre>

Answers (2)