title: A generic error occurred in GDI+. at System.Drawing.Image.Save
body: <p>Hi I am getting this error while  saving an Image at the given path</p>
  
  <pre><code>string WriteImage(string data, string imgPath)
  {           
      try
      {
          data = "*" + data + "*";
          Bitmap barcode = new Bitmap(1, 1);
          Font threeOfNine = new Font("IDAutomationHC39M", 60, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
          Graphics graphics = Graphics.FromImage(barcode);
          SizeF dataSize = graphics.MeasureString(data, threeOfNine);
          barcode = new Bitmap(barcode, dataSize.ToSize());
          graphics = Graphics.FromImage(barcode);
          graphics.Clear(Color.White);
          graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
          graphics.DrawString(data, threeOfNine, new SolidBrush(Color.Black), 0, 0);
          graphics.Flush();
          threeOfNine.Dispose();
          graphics.Dispose();
          barcode.SetResolution(300, 300);
          barcode.Save(imgPath, System.Drawing.Imaging.ImageFormat.Jpeg);
          return imgPath.Substring(imgPath.LastIndexOf("\\")+1);
      }
      catch
      {
          return "";
      }
  }
  </code></pre>
  
  <p>Dont know what i am doing wrong. </p>