On Wed, 22 Sep 2004 13:25:03 +0200, Mark wrote:
Hello,
Say I write a picture file to: 'c:\test.jpg'
Then I assign this picture to a picturebox
PbFoto.Image = Image.Fromfile("c:\test.jpg")
Next I want the overrwrite the file test.jpg with another picture.
When running, he says the file is in use when I want to overwrite it.
(if not assignd to the picture box, I can overwritte as many as I want)
I've tried 'PbFoto.Image = Nothing', but that didn't help also.
Anyone an idea how to free the file?
Look elsewhere in these groups for more information, but I believe the
solution offered is to use the FromStream method instead of using the
Image.FromFile method. When using FromStream, the file is not locked.
Perhaps this code can help:
Imports System.IO
Imports System.Drawing
Dim fs As System.IO.FileStream
fs = New FileStream("C:\test.jpg", FileMode.Open, FileAccess.Read)
PictureBox1.Image = Image.FromStream(fs)
fs.Close()
--
Chris
dunawayc[AT]sbcglobal_lunchmeat_[DOT]net
To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.