-
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.
-
Wow Guess what I Found using "Search"
Here :rolleyes:
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
-
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?
-
Anyone?
This can't be that hard or something...
Besides, this is very important...
Still many thanks for any help!
-
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.