I'm loading a file:
System.Drawing.Image img = System.Drawing.Image.FromFile(FilePath);
Now I would like to save the image:
img.Save(SavePath);
This works.. Unless FilePath == SavePath
, then it decides to give me the error:
System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
So I tried to delete the file, right after opening it:
System.Drawing.Image img = System.Drawing.Image.FromFile(FilePath);
File.Delete(FilePath);
And it gives me the error:
System.IO.IOException: The process cannot access the file 'filename.jpg' because it is being used by another process.
So... How can I modify an existing file, that's "in use" when its not in use by anyone?