Trocergian
10-04-2004, 01:40 PM
Here's the scenario:
I'm loading a graphic (.bmp) into a picture box. I then want to delete the file.
The problem, it won't let me as it says it's still in use.
I've tried doing a "picbox.image = nothing" first.
Same problem.
Is there some special commmand I need to release the file so I can perform another operation on it?
Thanks for any help.
Ziess
10-04-2004, 02:28 PM
are you just using the picture box, or are you opening the file?
-Ziess
Trocergian
10-04-2004, 02:50 PM
are you just using the picture box, or are you opening the file?
I am accessing the file via streamreader before displaying it, but I am closing the stream before trying to delete the file.
Trocergian
10-05-2004, 12:32 PM
Just to update....
I've since tried the dispose function, (on the picturebox)and still no go.
I then loaded the file into a new graphic object and diplayed that in the picturebox. Then did a dispose on the box and object. No help.
Also a little more detail:
I'm calling a form from my main form and loading a graphic file into the new forms picturebox. Even after closing the new form, I still cannot delete the graphic file (via windows explorer). Not until I totally close the application can I then delete the file. I've reduced the main form down to nothing but a button calling the new form. I do have a global module but it's just for declaring a few variables, nothing more.
Any ideas would be greatly appreciated - this is drving me insane!
Thanks.
herilane
10-05-2004, 12:39 PM
Could you post your code?
Please use vb] and [/vb to format the code.
Trocergian
10-05-2004, 01:24 PM
Right after posting my last message I went back and played around again with creating a new bitmap object and using that.
Lo and behold I got it working!
I'm not sure why it didn't work before, but now that is I'm not going to gripe.
Just as an FYI and to help somebody else with this problem
I declared a module level variable:
Public m_bmpMessage As Bitmap
Then filled it on load with:
m_bmpMessage = New Bitmap(filename)
And inserted into the picturebox:
picMessage.Image = m_bmpMessage
Finally, on closing I did:
picMessage.Dispose()
m_bmpMessage.Dispose()
Kill(filename)
-----------------------------
Helen - Thanks for the offer of help, as I was getting close to setting my hair on fire, tearing off my clothes, and running out into traffic. Fortunately, dumb luck intervened and I stumbled into a solution.