cannot delete this file because it is used by another process.
The message isn't terribly helpful to programmers because when it happens when you develop code, that other process is almost always your process.
This is very likely to occur with image files, creating a Image or Bitmap object from an image file puts a lock on the file. The lock is created because GDI+ creates a memory-mapped view on the file content, a strong optimization that keeps the bitmap data out of the paging file. Matters a great deal on large images, they can contain many megabytes worth of pixel data.
That lock is kept until you explicitly call its Dispose() method in your code. So be sure that was done before you try to save the image back. In rare cases you may need to create a copy of the image to allow you to dispose the original, use the Bitmap() constructor overload that takes an Image argument.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…