|
-
Oct 27th, 2000, 05:59 PM
#1
Thread Starter
Hyperactive Member
Hi all!
I tried to download a file through iNet control. I know the exact location of a file and I want to download it to a folder and show it in a label. Here's a description for the thing I'm trying to do.
URL: ftp.xoom.com/ultimateam
Source File: News.txt
Target File: App.Path & "/History/News/News.txt"
How can I do this? I beat the hell out of myself trying to figure this out.
Please help me!
Any help appriciated!
,Asaf Sagi.
-
Oct 27th, 2000, 06:25 PM
#2
Hyperactive Member
Wow Guess what I Found using "Search"
Here 
Code:
Private Sub Command1_Click()
Dim iFile As Integer
Dim bBIN() As Byte
bBIN = Inet1.OpenURL("www.vb-world.net/images/vbworld.gif", icByteArray)
iFile = FreeFile
Open "C:\vbworld.gif" For Binary Access Write As iFile
Put #iFile, , bBIN
Close iFile
End Sub
[]P
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Oct 27th, 2000, 06:40 PM
#3
Thread Starter
Hyperactive Member
Thanks Private1, it works fine with the gif but when I download a textfile which called News.txt and contains in it only "mana" so it downloads it and shows me tons of HTML crap.
Any suggestions?
-
Oct 27th, 2000, 07:07 PM
#4
Thread Starter
Hyperactive Member
Anyone?
This can't be that hard or something...
Besides, this is very important...
Still many thanks for any help!
-
Oct 27th, 2000, 07:12 PM
#5
That's because it's protocol is icByteArray which is for downloading pictures and images. Change it to icString which is for text.
Code:
Private Sub Command1_Click()
Dim x As String
x = Inet1.OpenURL("http://forums.vb-world.net", icString)
ReturnStr = Inet1.GetChunk(2048, icString)
Do While Len(ReturnStr) <> 0
DoEvents
x = x & ReturnStr
ReturnStr = Inet1.GetChunk(2048, icString)
Loop
End Sub
Or you can also use the URLDownloadToFile api function to download it to a file. Take a look at this tip from Vb-World that will show you how and open it.
The reason why you should use the URLDownloadToFile api function as an alternative is because MSInet is very unreliable. Very buggy (times out) and doesn't get the whole page sometimes, just half.
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
|