 |
|

03-03-2002, 09:16 AM
|
|
Junior Contributor
|
|
Join Date: Jan 2002
Location: germany, frankfurt
Posts: 267
|
|
download files
|
I like to download .ZIP files from a http address (no ftp!) and store them to the harddisk.
I'm not sure if I have to use inet or winsock to do this.
With inet I was able to download from ftp only not http :-(
Thanks for help
Stefan
|
|

03-03-2002, 09:55 AM
|
 |
A+ Certified Nerd
Retired Leader * Expert *
|
|
Join Date: Dec 2001
Location: East Coast
Posts: 1,763
|
|
Inet will work apparently
__________________
If you're not part of the solution, you're part of the precipitate.
|

03-03-2002, 12:11 PM
|
|
|
|

03-03-2002, 04:50 PM
|
|
Junior Contributor
|
|
Join Date: Jan 2002
Location: germany, frankfurt
Posts: 267
|
|
|
Thanks,
in the meantime I found a way to download with the inet also with http. :-))
One more question:
How can I get the filesize before I start the download as I like to show the percent of the downloaded file with a processbar.
Thanks for help again.
|
|

03-04-2002, 05:06 AM
|
|
Junior Contributor
|
|
Join Date: Jan 2002
Location: germany, frankfurt
Posts: 267
|
|
I use
Code:
bData() = Inet.OpenURL(strURL, icByteArray)
in order to download a file now, but how can I get the filesize for this file???
Thanks for help.
|
|

03-04-2002, 05:46 AM
|
 |
Funky Monkey
* Expert *
|
|
Join Date: Nov 2001
Location: England
Posts: 1,289
|
|
|
Why do you call yourself Wendy when your name is Stefan?
|
|

03-04-2002, 05:50 AM
|
|
Junior Contributor
|
|
Join Date: Jan 2002
Location: germany, frankfurt
Posts: 267
|
|
|
it is a nickname as my lastname is wendt :-)
As Stefan was already used when I create this user I used wendy as user.
Stefan (or wendy)
|
|

03-04-2002, 12:26 PM
|
|
Junior Contributor
|
|
Join Date: Jan 2002
Location: germany, frankfurt
Posts: 267
|
|
Hello again,
it seems that my problem regarding the filesize is not as easy as I get no reply :-(
Maybe someone can help for this:
How can I see if a download has ended without errors, or if the filename was correct?
with
Code:
Private Sub Inet_StateChanged(ByVal State As Integer)
I can see many connection states but no state if download has finished with or without error :-(
Thanks again for a hint if I have to use winsock for these features.
Stefan
|
|

03-04-2002, 01:03 PM
|
 |
ISearchGoogle
Retired Moderator * Expert *
|
|
Join Date: May 2001
Location: england
Posts: 6,321
|
|
You need to use the icHTTP protocol to send a "GET" request to the server. The server will then respond with all sorts of information about the file you are trying to GET, including its size!
From there, within the Inet1_StateChanged() event of the Inet control, use the GetChunk() method to retrieve a fixed size chunk of the file.
You can then update the progress bar using a simple formula between how large the file is, and how much you've got already.
Edit: Here is a good link explaining the usage of the Inet control for file downloading. Enjoy.
|
__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
|

03-04-2002, 01:31 PM
|
|
Junior Contributor
|
|
Join Date: Jan 2002
Location: germany, frankfurt
Posts: 267
|
|
|
ChiefRedBull,
maybe you have a example code for this.
I tried this many times but it did not work :-(
HELP
|
|

03-04-2002, 01:38 PM
|
 |
ISearchGoogle
Retired Moderator * Expert *
|
|
Join Date: May 2001
Location: england
Posts: 6,321
|
|
|
I dont have any no, but I'll knock one together for you. Give me a day or two so its bug free enough to go in the Code Library when its done.
Until then - read and understand that link i gave you.
|
__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
|

03-04-2002, 01:56 PM
|
|
Junior Contributor
|
|
Join Date: Jan 2002
Location: germany, frankfurt
Posts: 267
|
|
|
thats great :-))
I already read it, but with HTTP it is not working :-(
I will try to find more informations about this topic in order to understand what a made wrong.
Stefan
|
|

03-04-2002, 03:21 PM
|
 |
ISearchGoogle
Retired Moderator * Expert *
|
|
Join Date: May 2001
Location: england
Posts: 6,321
|
|
HTTP is working.... and is proven by my nice little demo.
With a little searching on the net, I found this helpful site, and plenty of others.
My example is posted in the Code Library.
|
__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
|

03-05-2002, 12:24 PM
|
|
Junior Contributor
|
|
Join Date: Jan 2002
Location: germany, frankfurt
Posts: 267
|
|
|
Thank you :-)
I already tested your code and the link you gave me, very interesting.
In the most cases I'm able to download the files but with some Links I can't receive the Header information, thus I receive a error 'icRequestFailed' in State 8.
This problem happend when the URL is as
'http://testserver.com/download.cfm?filename=mytestfile.zip'
When I use the IE with this URL it works! Any idea ??
I have no problems we I try to download files with following "style":
'http://www.testserver.com/download/test.zip'
One more question:
As I like to download more then one file (in sequence or at the same time) I tried to modify the code with a little loop but it doent work :-(
How can I download more than one file - it doesn't matter if async or sync.
Thanks for your professional help again.
Stefan
|
|

03-05-2002, 03:20 PM
|
 |
ISearchGoogle
Retired Moderator * Expert *
|
|
Join Date: May 2001
Location: england
Posts: 6,321
|
|
To download more than one file at a time is going to require specific code for your program. A loop will probably be needed somewhere, but I couldn't help more without actually seeing your code.
As for downloading from 'funny' URLs.... it should work fine. I just successfully downloaded this url
Code:
http://www.xtremevbtalk.com/attachment.php?postid=93137
Could you give me an actual example on the ones that aren't working?
|
__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
|

03-06-2002, 04:34 AM
|
|
Junior Contributor
|
|
Join Date: Jan 2002
Location: germany, frankfurt
Posts: 267
|
|
I used the code from the library you provided and add a loop as follow:
Code:
Private Sub cmdGetFile_Click()
Do
i = i + 1
lURL = URL(i)
Inet.Protocol = icHTTP
Inet.Execute lURL, "GET"
Loop Until i = maxURL
End Sub
Where array URL(i) inculdes different URLs.
When I use this code only URL(i=maxURL) is downloaded, what means if maxURL=4, only URL(4) is downloaded but not URL(1..3).
Any idea why?
Regarding my other problem I suppose the problem was located to the fileserver as I had no problems to download single files
today :-)
Stefan
|
|

03-06-2002, 04:43 AM
|
 |
A+ Certified Nerd
Retired Leader * Expert *
|
|
Join Date: Dec 2001
Location: East Coast
Posts: 1,763
|
|
I'm not not sure if this will help, but you might want to try a For...Next loop instead. Like this:
Code:
For i = 1 To maxURL
lURL = URL(i)
Inet.Protocol = icHTTP
Inet.Execute lURL, "GET"
Next i
|
__________________
If you're not part of the solution, you're part of the precipitate.
|

03-06-2002, 05:13 AM
|
 |
ISearchGoogle
Retired Moderator * Expert *
|
|
Join Date: May 2001
Location: england
Posts: 6,321
|
|
Once you've executed the "GET" request, you need to wait until that file has been downloaded before you execute another "GET" request, other wise your program will get confused, and not finish off any of the downloads completely.
TO this end, I suggest you have a form level boolean variable, called bflDownloadDone.
Set it to false before you execute, then when the download is completed set it to true.
Code:
For i = 1 To maxURL
lURL = URL(i)
Inet.Protocol = icHTTP
bflDownloadDone = False
Inet.Execute lURL, "GET"
' do nothing until the file has been
' successfully downloaded
Do While bflDownloadDone = False
DoEvents
Loop
Next i
In the Inet_StateChanged event, once you've saved the incoming file to disk, set the bflDownloadDone to True.
You might also want to have an error flag in there as well, so that if the download errors, your Do While bflDownloadDone = False loop doesn't continue for ever...
|
__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
|

03-06-2002, 08:02 AM
|
|
Junior Contributor
|
|
Join Date: Jan 2002
Location: germany, frankfurt
Posts: 267
|
|
|
It works, but only when I run the program in VB6.
When i create a .exe the program freez when I like to start the download :-(
could this be a problem of ' DoEvents' ?
I'm not sure what this command realy do.
Thanks for your help again!!
Stefan
|
|

03-06-2002, 12:08 PM
|
 |
ISearchGoogle
Retired Moderator * Expert *
|
|
Join Date: May 2001
Location: england
Posts: 6,321
|
|
DoEvents passes control back to the Windows OS, and allows it to catch up with any tasks that need doing. It basically means that your program doesn't take up all the resources of the system, and it also gives a little pause, to allow things like Winsock.SendData to complete successfully.
If you did a loop like this:
Code:
Do While bFlag = False
Loop
your program is likely to crash, or show up as [not responding] in the Task Manager.
Could you post the source thats causing the problem? If its quite long, attach a ZIP containing all the project files.
|
__________________
Chuck Norris ordered a Big Mac at Burger King, and got one.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|