|
-
Apr 22nd, 2007, 12:42 PM
#1
Thread Starter
Member
[2005] DownloadStringAsync - How?
I need to download the HTML of a web page but don't need to display it, so I'm changing my existing (working) code from a webbrowser class to the webclient class. The problem I'm having is that the URL needs to change programmatically as I will go through a list of them.
I can't seem to get the definitions and call right. I finally seemed to get the definitions right, but I get a squiggly line under the call. Here's what I have right now:
Code:
'I'm just trying to get the URL into a string that I can
'feed the URI in code as a variable because the URL will
'change as multiple pages are processed.
Dim strPath As String = txtUrl.Text.ToString
Dim URL As New Uri(strPath)
Using wcWebClient As New System.Net.WebClient
txtSource.Text = wcWebClient.DownloadStringAsync(URL)
End Using
Like it is, I get a squiggly line under wcWebClient.DownloadStringAsync(URL). When I hover over it, the tooltip says:
"Expression does not produce a value."
If I just type the url in directly like this:
Code:
txtSource.Text = wcWebClient.DownloadStringAsync("http://www.somedomain.com/misc-page.htm")
The squiggly line changes to a different error in the tooltip:
"Value of type 'String' cannot be converted to 'System.Uri'."
What am I doing wrong? I've searched on here and there are no threads containing DownloadStringAsync. I've searched the MSDN forums and what little information that's there is all in C#. The documentation tells about it, but doesn't show an example of doing it programmatically, only a single URL, entered directly in the .DownloadStringAsync call like the bottom example above. I don't understand why mine says "Value of type 'String' cannot be converted to 'System.Uri'" when I do it the same way. Its the URI thats screwing me up, I don't know how to use it properly.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|