Results 1 to 2 of 2

Thread: Update BackGroundImage - problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    4

    Update BackGroundImage - problem

    Could anyone tell me why this works the first time but not the second time it's called:

    Dim wc As New System.Net.WebClient()

    wc.DownloadFile("http://217.37.196.12/halfsize.jpg", _
    "c:\pic.jpg")

    Dim bgImage As Image = Image.FromFile("C:\pic.jpg")

    Panel1.BackgroundImage = bgImage

    I think it's because I'm trying to download the file again to the same filename which is in use.

    Could anyone suggest a workaround?

    Many thanks,

    Dan

  2. #2
    New Member
    Join Date
    Sep 2002
    Location
    tennessee
    Posts
    7
    I would break it out into two functions,

    Code:
    public sub Download_Image(byval URL as string, byval filename as string)
    
    Dim wc As New System.Net.WebClient()
    
    wc.DownloadFile(url, filename)
    
    end sub
    
    public sub SetBackground(byval filename as string)
    
      Dim bgImage As Image = Image.FromFile(filename)
    
      Panel1.BackgroundImage = bgImage
    end sub
    then you can just call the second function as manay times as you want. I would also see what panel1.refresh does for you.
    Last edited by lault; Sep 19th, 2002 at 04:39 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width