[RESOLVED] [2005] File is used by Another Program
Dear All,
I have loaded a Image in a Imagebox from a localpath.Now I want to delete the image from the physical location.I am getting an error message that
"the file is used by another window".How to rectify this problem.
I am trying to delelte file as
VB Code:
My.Computer.FileSystem.DeleteFile(tempFile & "." & extension)
How to clear the image from the Imagebox.
Thanks in Advance,
Dana
Re: [2005] File is used by Another Program
How did you load the image?
Re: [2005] File is used by Another Program
Thanks jmcilhinney
VB Code:
frmerrorpicture.pict_Error.Image = Image.FromFile(sc.tempFile & ".jpeg")
Re: [2005] File is used by Another Program
From the MSDN help topic for the Image.FromFile method:
Quote:
The file remains locked until the Image is disposed.
In .NET 2.0 call the Load method of the PictureBox, which doesn't lock the file.
Re: [2005] File is used by Another Program
Thanks jmcilhinney,
It works like a charm. :)
Dana