If you want to do this only with code (without Internet port control), VBNet.mvps.org has a really good practical article that uses the URL URL URLDownloadToFile API.
From the article:
The URLDownloadToFile API is available on all versions of the Windows operating system (except Win3, WinNT3.x). By passing the remote file the name and path and name of the local file, the API loads a bit of the specified file and saves them as the target name. The function works with all types of files - plain text, images, html, mpg, wav and zip files, etc. without changing the procedure or caring for the download file, and there is no visible size limitation or limitation.
Private Declare Function URLDownloadToFile Lib "urlmon" _ Alias "URLDownloadToFileA" _ (ByVal pCaller As Long, _ ByVal szURL As String, _ ByVal szFileName As String, _ ByVal dwReserved As Long, _ ByVal lpfnCB As Long) As Long Private Const ERROR_SUCCESS As Long = 0 Private Const BINDF_GETNEWESTVERSION As Long = &H10 Private Const INTERNET_FLAG_RELOAD As Long = &H80000000 Public Function DownloadFile(sSourceUrl As String, _ sLocalFile As String) As Boolean //'Download the file. BINDF_GETNEWESTVERSION forces //'the API to download from the specified source. //'Passing 0& as dwReserved causes the locally-cached //'copy to be downloaded, if available. If the API //'returns ERROR_SUCCESS (0), DownloadFile returns True. DownloadFile = URLDownloadToFile(0&, _ sSourceUrl, _ sLocalFile, _ BINDF_GETNEWESTVERSION, _ 0&) = ERROR_SUCCESS End Function
FYI - when testing in Windows 7, it will only return the cached version, so I had to use the additional function mentioned in the article to clear it first (and it worked).
Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _ Alias "DeleteUrlCacheEntryA" _ (ByVal lpszUrlName As String) As Long
Then first call the above function with the destination URL to clear the cache.
C-pound guru
source share