Hi...
I wrote code using vb.net
picturebox1.image=image.Fromfile("C:\a.jpg")
picturebox1 display image a.jpg.

if picturebox1 display, file a.jpg can't delete it because "being used by another person".
how to close picturebox1 so file a.jpg can delete?

i have tried to use picturebox1.dispose() and picturebox1.image=nothing but still can delete and display error message "being used by another person"

thanx

Recommended Answers

All 7 Replies

Learn about Resources.

Hi...
I wrote code using vb.net
picturebox1.image=image.Fromfile("C:\a.jpg")
picturebox1 display image a.jpg.

if picturebox1 display, file a.jpg can't delete it because "being used by another person".
how to close picturebox1 so file a.jpg can delete?

i have tried to use picturebox1.dispose() and picturebox1.image=nothing but still can delete and display error message "being used by another person"

thanx

Hi,
you need to use :- PictureBox1.Image.Dispose() by using dispose on the picturebox, you are not disposing the image itself.

Hi,
you need to use :- PictureBox1.Image.Dispose() thanx for your reply,
by using dispose on the picturebox, you are not disposing the image itself.

Picturebox1.image.dispose() can't delete and display error
if user vb 2005,2008 can use picturebox1.image=nothing to close and delete/rename that image file.
but i have tried use vb 2003 and result can't rename that image file

i use vb.2003
thanx

i m facing the same in vb.net 2008

i think it's just like when you're opening a file using file stream that's why it prompts the message that it's being used..

try this
then after closing, delete the file

hope this helps,

i have found some different and it is working.
i.e.

Use picturebox1.dispose() instead of picturebox1.image.dispose().

I need to determine which tab the user is coming from, and going to, when they switch tabs, and possibly cancel the switch. I have tried the Deselecting, Deselected, Selecting, Selected events, and all of them show the e.TabPageIndex to be the same as the sender.SelectedIndex.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.