How do i download a file from the internet?
What i want to do is to make a program to download 'Free program of the day' from my site which i am thinking to create later.
Printable View
How do i download a file from the internet?
What i want to do is to make a program to download 'Free program of the day' from my site which i am thinking to create later.
Use the Inet Control (MSINET.OCX)
This will downlaod a pretty cool program. :) enjoyCode:Private Sub DownloadFile(ByVal URL as String, ByVal LocalFile as String)
Dim b() as Byte
Open LocalFile for Binary As #1
b() = Inet1.OpenURL(URL, icByteArray)
Put #1, , b()
Close #1
End Sub
Private Sub cmdGetUpdate_Click()
DownloadFile "http://free.digitalriver.com/pub/strata3/strata3d.zip", "C:\strata3d.zip"
End Sub
If you don't need that much costumization but a reliable method I suggest using the API.
http://www.vb-world.net/internet/tip501.html
and if you need a dialog (with the progress/speed and stuff, just the general download-dialog used in IE
Have fun!!!Code:'[begin of code]
'Author: Brad Martinez
'Origin: http://www.mvps.org/vbnet/code/netwo...ledownload.htm
'Purpose: Download a file via the file-download dialog
'Version: VB5+
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2000 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' You are free to use this code within your own applications,
' but you are expressly forbidden from selling or otherwise
' distributing this source code without prior written consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long
Private Sub DownloadFile(Url As String)
Url = StrConv(Url, vbUnicode)
Call DoFileDownload(Url)
End Sub
'[end of code]
Thank you both. That was a great help.