Click to See Complete Forum and Search --> : Try to delete a picture file which is loaded in picturebox


aviskumar
August 23rd, 2005, 01:18 AM
Hi,

i tried to delete a picture file which is loaded in picturebox using system.io.file.delete method it gives error that "It being used by another Process".

How to overcome this error. still i used picturebox =null

Regards,
Sivakumar.kr

jmcilhinney
August 23rd, 2005, 02:21 AM
The help documentation clearly states that if you have created an Image object by calling Image.FromFile then that file is locked until the Image object is Disposed. This means that you need to call Dispose on the PictureBox.Image to release the file. You can use Image.FromStream to create an Image without locking the file in the first place.

Norfy
August 23rd, 2005, 02:31 AM
jmcilhinney is correct, here is another alternative...something similar on another thread (http://www.codeguru.com/forum/showpost.php?p=908026&postcount=12)