Hi forum,

I wish to open a Image file, modify it, then save it.

To open the image, I simply use the following code
Code:
 // BACKGROUND
            Image buffer = new Bitmap(backgroundFilename);
            background = (Image)buffer.Clone();
            buffer.Dispose();
            buffer = null;
Now if I want to save to this existing file, I do the following
Code:
Bitmap bmp = new Bitmap(1024, 512);
Graphics g = Graphics.FromImage(bmp);
g.DrawImage(background, 0, 0);

 if (File.Exists(backgroundFilename))
            {
                File.Delete(backgroundFilename);
            }

            bmp.Save(backgroundFilename, System.Drawing.Imaging.ImageFormat.Png);
with the idea that if it already exists (which it does because I opened it), delete it then re-save it.

However, on the File.Delete line, C# crashes with a "This file is being used by another process"

Its obvious I am doing something wrong when opening the file, but not sure what.

Thanks