ADO DOT NET Posted February 11, 2008 Posted February 11, 2008 Hi, I want to download a string from a page in my site, so I use this and it works: NewString = WebClient.DownloadString("http://www.domain.com/setup.txt") Just 1 problem that if there is a connection timeout, my application hangs out. So should I use WebClient.DownloadStringAsync? If so how? I wrote this code but it doesn't work: Dim SiteURI As New Uri("http://www.domain.com/setup.txt") NewString = WebClient.DownloadStringAsync(SiteURI) Please help me :( Quote
Administrators PlausiblyDamp Posted February 12, 2008 Administrators Posted February 12, 2008 Chuck this into a blank form and you should get the general idea Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim SiteURI As New Uri("http://www.xtremedotnettalk.com/showthread.php?p=465032#post465032") Dim wc As New WebClient wc.DownloadStringAsync(SiteURI) AddHandler wc.DownloadStringCompleted, AddressOf Test End Sub Private Sub Test(ByVal sender As Object, ByVal e As DownloadStringCompletedEventArgs) Dim newstring As String = e.Result End Sub Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.