I have a C# win form application that sets a new image = to an image from a file. Like this:
var displayPicture = Image.fromFile(/*path*/);
PicBoxPictureDisplay.BackgroundImage = displayPicture;
But when I go to delete it with:
File.Delete(/*path*/);
I get: "The process cannot access the file [name of file used in .FromFile]
How can I delete the .FromFile image?
Edit: the following methods fail;
- PicBoxPictureDisplay.BackgroundImage.Dispose();
- PicBoxPictureDisplay.BackgroundImage = null;
- displayPicture.Dispose();