Picture box locking image

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I suppose I must have missed something somewhere but I'm getting an error when trying to overwrite a file referenced by a picture box. Even if I set the image property to nothing I still get an error.

I read somewhere that using a filestream based on the image would eliminate this problem but it didn't.

Any ideas appreciated.

Steve
 
* =?Utf-8?B?U3RldmUgQnVnZGVu?= said:
I suppose I must have missed something somewhere but I'm getting an
error when trying to overwrite a file referenced by a picture box. Even
if I set the image property to nothing I still get an error.

Call the bitmap's 'Dispose' method before trying to delete the file.
 
OK I've got it now I think.

I for got to close the filestream. The following code seams to work for anyone who's interested:

Dim fs As System.IO.FileStream = New System.IO.FileStream(strImageFilename, FileMode.Open, IO.FileAccess.Read)
'load the picture box with the image
Me.picMainImage.Image = System.Drawing.Image.FromStream(fs)
fs.Close()

Steve.
 
Back
Top