|
-
Jul 10th, 2000, 11:21 PM
#1
Thread Starter
New Member
Hi,
I wanted to know if there is a way to get a progress bar
so when i download a file using Microsoft Internet Transfer Control 6.0, i can give a time left or amount complete
Here is how i called it if this helps
c() = Inet.OpenURL("http://www.foobar.com/highscore.dat", 1)
so i can't figure out anyway using this control to
get a value for ProgressBar.Value to use, is there
any other way to get this to work? or is there control
that i can use to download the file thats not to hard to use.
Thanks,
-
Jul 10th, 2000, 11:30 PM
#2
Hyperactive Member
Basically you need to know the size of the file first.
You might notice that some browsers will tell you exactly hwo big the file is before they start downloading while some dont.
I don't know exactly what does this but it has something to do with the protocol. A "call" is made to the web browser asking for the size of the particular file mentioned.. I think it is a request to the HTTP port to the web server using a specific instruction asking the web server to inform the caller how many bytes the file is in length.
Once you have this figure you can then use it to calculate the percentage complete (by subtracting total bytes received from this total and dividing by the total) and also the average amount of time taken to download (Take the total number of bytes downloaded and divide by the time taken to receive those bytes and expand it for the entire file).
If I were you I would have a look around the HTTP protocol, perhaps have a look for the parameters stored in the HTTP header that comes with every request.
You might find either the part of the protocol that asks for the files size or you might find a HEADER field that is passed with the request indicating its size.
-
Jul 10th, 2000, 11:50 PM
#3
Thread Starter
New Member
Hey,
That will work great i can figure out the file size, but do you know a way to figure out how many bytes have been transfered? or how fast they are being transfered?
Thanks
MusixMan
-
Jul 11th, 2000, 12:28 AM
#4
Hyperactive Member
Not sure with the Inet control....
But if you were using WinSock and downloading the file the "SendData" returns the number of bytes in the packet. You just keep accumulating them. Have a look in the help file about the inet control and see if there is a "bytesreceived" or something similar attribute.
As for the timing you can work that out once you have the bytes received.
A) Time 0:00:00 Received 1000 bytes
B) Time 0:00:04 Received 1000 bytes
Total Bytes = 2000
Total Time = 4 seconds
Rate = 2000 / 4 = 500 bytes/sec
C) Time 0:00:06 Received 1000 bytes
Total Bytes = 3000
Total Time = 6 seconds
Rate = 3000 / 6 = 500 bytes/sec
And so on
-
Jul 11th, 2000, 02:01 PM
#5
Fake it ;].
Code:
ProgressBar1.Max = 100
ProgressBar1.Min = 0
Screen.MousePointer = 11
For i = 0 To 50
ProgressBar1.Value = i
Next i
c = Inet1.OpenURL("http://www.foobar.com/highscore.dat", 1)
For i = 50 To 100
ProgressBar1.Value = i
Next i
Text1.Text = c
Screen.MousePointer = 0
-
Jul 12th, 2000, 05:31 PM
#6
Thread Starter
New Member
hehe,
yeah faking it works fine, hehe.
I ended up using winsock for it, nice it's a crappy program anyway but i can use the code in just about anything.
MusixMan
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
|