Update backGround Image, little help please :)
Hi!
I have the following code to download a JPEG from a website and display it as the background image in Panel (panel1) when I click a form button. This works fine the first time but if I try and click the button again it says the resource "c:\dan.jpg" is being used.
My question is is there a way to download an image from a site and update an image on a form time and time again - I'm not too experienced with VB.net so any help would be most appretiated
I've included my code below...
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim wc As New System.Net.WebClient()
wc.DownloadFile("http://***.**.***.**/halfsize.jpg", _
"c:\dan.jpg")
Dim backgroundImage As Image = Image.FromFile("C:\dan.jpg")
Panel1.BackgroundImage = backgroundImage
wc.Dispose()
Dim fsof As System.IO.File
fsof.Delete("c:\dan.jpg")
End Sub
Many thanks
da