..NET 2.0
I have an Image on my form and I am trying to clear this image and re-load
it with different image.
Everything works fine, but once I load the image I can not delete this image
until I close the program. How can I clear the image so I can delete it.
Here's my code:
string imgFileName = @"C:\myImage.jpg";
this.pic.Image = Image.FromFile(imgFileName);
//
// clear the image
//
this.pic.Image.Dispose();
this.pic.Image = null;
//
//
//
If I try to delete the image with Windows Explorer before I end the program
I get the following error message
---------------------------
Error Deleting File or Folder
---------------------------
Cannot delete 14036: It is being used by another person or program.
Close any programs that might be using the file and try again.
---------------------------
OK
---------------------------
Thank You
Peter