|
-
Apr 27th, 2005, 08:21 AM
#1
Thread Starter
Fanatic Member
Downloader
Hi all,
Need some help from you ppl. I want to develope a downloader program, where I can queue number of files to be downloaded from the web. I have got a following function, which I use to download individual file from the web:
VB Code:
Public Function DownloadFile(ByVal URL As String, ByVal LocalFileName As String) As Boolean
Dim myClient As New System.Net.WebClient
Dim S As System.IO.FileStream
Dim myBuffer As Byte()
Try
myBuffer = myClient.DownloadData(URL)
S = New IO.FileStream(LocalFileName, IO.FileMode.OpenOrCreate)
S.Write(myBuffer, 0, myBuffer.Length)
S.Flush()
Catch
Finally
If Not S Is Nothing Then S.Close()
myClient.Dispose()
End Try
If Not myBuffer Is Nothing Then Return True
End Function
This function is working fine, but the problem with using this function for multiple downloads are:
1. I cannot terminate the downloading process inbetween.
2. Cant show a progress bar while downloading.
3. There are various URLs which have asp or php path, wherein giving a destination path is troublesome.
Pls pass on your suggestions and ideas.
Cheers n Regards
-
Apr 27th, 2005, 08:50 AM
#2
Addicted Member
Re: Downloader
1. I cannot terminate the downloading process inbetween.
Sure you can, start the download function in a separate thread.
There are no stupid questions, but a whole bunch of dumb sayings !
Save time on database code, try DataLG !
-
Apr 27th, 2005, 09:01 AM
#3
Thread Starter
Fanatic Member
Re: Downloader
Can you give me a sample code please. Never done threading!!
-
Apr 27th, 2005, 09:14 AM
#4
Addicted Member
There are no stupid questions, but a whole bunch of dumb sayings !
Save time on database code, try DataLG !
-
Apr 27th, 2005, 09:19 AM
#5
Thread Starter
Fanatic Member
Re: Downloader
Thats cool...will go thru it. What abt other queries? You have any better solution to dload multiple files?
-
Apr 27th, 2005, 10:38 AM
#6
Hyperactive Member
Re: Downloader
Threading is the solution to your 2nd problem as well however i am not sure about the 3rd one.
I have made a Download Manager through Threading and it is very easy using Threads.Also u can use the Threads for showing the Progress bar and terminating the Download in Between.
Please tell me the Solution of your 3rd question if u find it anywhere.
-
Apr 28th, 2005, 02:23 AM
#7
Thread Starter
Fanatic Member
Re: Downloader
How would u increament the progress bar?
One more question? I am displaying the list of downloads on the flexigrid. How to insert progress bar in the flexi grid for each download?
thanx in advance
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
|