Hi.
I am working on an imaging project, and I've run across a problem I can't seem to solve. Most of my experience is in VB6 and never did any type GDI stuf there.
Anyway, I have an imagelist control on my main form. I pass it to a routine in a seperate VB module where I populate it like this:
Dim myDirectoryInfo As DirectoryInfo = New DirectoryInfo(ParsedCommandList("PHOTODIR"))
For Each myFileInfo As FileInfo In myDirectoryInfo.GetFiles
Dim CachedFileName As String = My.Application.Info.DirectoryPath & "\cache\" & myFileInfo.Name
myFileInfo.CopyTo(CachedFileName, True)
SketchImageList.Images.Add(myFileInfo.Name, Image.FromFile(CachedFileName))
Next
Now, if I reload the pictures again, I get a file in use message on this line:
myFileInfo.CopyTo(CachedFileName, True)
I've tried re-instantiating the imagelist control, tried dispose methods. Nothing short of stopping the application and restarting it releases the file. For example:
For Each image As Image In SketchImageList.Images
image.Dispose()
Next
SketchImageList.Dispose()
)
What do I need to do to get my program to release this file?
Thanks!
Enter your message below
Sign in or Join us (it's free).