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

Re: Picture box locking image by hirf-spam-me-here

hirf-spam-me-here
Sun Jan 25 05:44:15 CST 2004

* =?Utf-8?B?U3RldmUgQnVnZGVu?= <anonymous@discussions.microsoft.com> scripsit:
> 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.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

RE: Picture box locking image by anonymous

anonymous
Sun Jan 25 05:51:05 CST 2004

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.