Results 1 to 2 of 2

Thread: WebClient only works once?!

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2007
    Posts
    360

    WebClient only works once?!

    Code Code:
    1. Dim myWebClient As New WebClient()
    2.         ' Me.Text = "Downloading Image"
    3.         Dim img As HtmlElement
    4.         For Each img In WebBrowser1.Document.Images
    5.             If img.OuterHtml.Contains("vacation") Then
    6.                 Dim fileName As String = "vacation.jpg"
    7.                 Dim myStringWebResource As String = Nothing
    8.                 myStringWebResource = img.GetAttribute("src")
    9.                 myWebClient.DownloadFile(myStringWebResource, fileName)
    10.                 myWebClient.CachePolicy = New RequestCachePolicy(RequestCacheLevel.NoCacheNoStore)
    11.             End If
    12.         Next

    On each refresh in webbrowser1 the "vacation" image changes. I need it to download the new image every time.

    It only downloads an image once. If I have it download again it will only download the last image which is why I thought it was caching it - not doesn't seem to be the issue because I made webclient nocache/nostore.

    I launch the program - and it downloads the new image.

    It will not download an image twice... It seems like it is caching the first but heh...

    What's going on?

    Update:

    It looks like it can't overwrite vacation.jpg with the new image because its in use... I tried to do " myWebClient.Dispose()" but that doesn't fix the problem.
    Last edited by thud; Apr 12th, 2008 at 10:25 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