Delete Picture Box Picture

hercemer

Member
Joined
Apr 21, 2003
Messages
11
I hope I am posting this in the right place.

I am making a PictureBox that shows a file called lookoout.jpg
The lookout.jpg is generated by a motion camera (everytime there is motion).

What I would like, is for the PictureBox to Display Lookout.JPG, and then delete the lookout.jpg (and then display it again while the other image is still showing).

Form2 just has a picture box on it, with a close button.

-------------------------------------------
Dim form2settings As New Form2()
form2settings.Show()
-------------------------------------------
Close Button -
-------------------------------------------
System.IO.File.Delete("lookout.jpg")
--------------------------------------------

Proble: lookoout.jpg is in use by the PictureBox, and cannot be deleted. Is there a way to load the picture into memory so I can delete the original file?

Thanks in advance!!
 
Try this:
Code:
Dim b As Bitmap = New Bitmap("lookout.jpg")
Dim newBitmap As Bitmap = b.Clone();
PictureBox1.Picture = newBitmap

I havent tested this... :)

-Nerseus
 
I tried:
------------------------------------------------------------------------
Dim b As Bitmap = New Bitmap("lookout.jpg")
Dim newBitmap As Bitmap = b.Clone()
b.Dispose()
PictureBox1.Image = newBitmap
------------------------------------------------------------------------
But file is still in use when picture is displayed.

Thanks for the idea tho
 
Back
Top