Program freeze when using WebClient
- From: Eric Helgeson via .NET 247 <anonymous@xxxxxxxxxxxxx>
- Date: Wed, 30 Mar 2005 15:33:25 -0800
Hey-
I made a program that gets some html and grabs all the URL's that end with .bin (threw regexp) and pass it to a function i have called DownloadFile(url)
The problem is that my whole app is locked untell the prossess completes. I even have some text before the function call that isnt shown untill after. If i put a message box inbetween function calls (i was just testing) it will show the text outputs. I've been reading some async stuff but i cant get it implemented. Any help would be great, thanx.
Code:
Function DownLoadFile(ByVal remoteUri As String)
Dim myStringWebResource As String = remoteUri
Dim myWebClient As New WebClient
Dim i As Integer = InStrRev(remoteUri, "/")
Dim fileName As String = Mid(remoteUri, i + 1)
txtMessages.Text = "Downloading File from: " & myStringWebResource
If System.IO.File.Exists(Application.StartupPath & "\Updates\" & fileName) Then
txtProgress.Text &= fileName & " Exists Already." & ControlChars.NewLine
Return 0
End If
myWebClient.DownloadFile(myStringWebResource, Application.StartupPath & "\Updates\" & fileName)
myWebClient.Dispose()
txtProgress.Text &= "Successfully Downloaded file " & fileName & ControlChars.NewLine
End Function
PS: ideas for the future include a progress bar and compair file sizes (from server and from local)
--------------------------------
From: Eric Helgeson
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>m6EHaBPt306ssL8QHjelcw==</Id>
.
- Prev by Date: Re: Creating WS Client without access to Web Service
- Next by Date: Some questions on ASP.NET web services on IIS 6
- Previous by thread: Re: 401 Error Webservice. I WANT anonymous access
- Next by thread: Some questions on ASP.NET web services on IIS 6
- Index(es):
Relevant Pages
|