This question has been asked multiples times but none has helped.. I am trying to draw a rectangle on a image and save the image but while save its throwing "A generic error occurred in GDI+"
Bitmap bm = new Bitmap(path);
// Draw the rectangle.
using (Graphics gr = Graphics.FromImage(bm))
{
Pen blackPen = new Pen(Color.Red, 103);
gr.DrawRectangle(blackPen, x1, y1, Width, Height);
bm.Save(path);
}
Even when trying to delete the file before saving it throws "the file has been used by another proccess".