LarryDietz
Member
I am working on a program that loads images into a picturebox, using the following line of code...
This loads the image just fine. However, when I load a 2nd image (or 3rd, etc...) it continues to hold the previous files open.
If I load 5 images (1 at a time) then go to windows explorer and try to delete one of the first images (which is no longer being displayed) the system will not let me. It give the following error...
It appears to be locking ALL the images it has ever opened, until I shutdown the program.
This is a problem because I need the program to be able to delete some of these files.
Does anyone have any idea why this error is occuring?
Any help would be greatly appreciated.
-Larry
Code:
picScreenShot.Image = Image.FromFile(Application.StartupPath + "\screenshots\" + GameList(SelectedGame).InternalName + ".png")
This loads the image just fine. However, when I load a 2nd image (or 3rd, etc...) it continues to hold the previous files open.
If I load 5 images (1 at a time) then go to windows explorer and try to delete one of the first images (which is no longer being displayed) the system will not let me. It give the following error...
An unhandled exception of type System.IO.IOException occurred in microsoft.visualbasic.dll
Additional information: The process cannot access the file "...\screenshots\testfile.png" because it is being used by another process.
It appears to be locking ALL the images it has ever opened, until I shutdown the program.
This is a problem because I need the program to be able to delete some of these files.
Does anyone have any idea why this error is occuring?
Any help would be greatly appreciated.
-Larry