How to write a micro to download file at a URL save the file at the local PC
Thanks
How to write a micro to download file at a URL save the file at the local PC
Thanks
Have a look at this windows api call:
URLDownloadToFile
Be aware thought that MS appears to have changed how this functions with
recent service packs / security updates, without any documentation or
notification, so that it will not retrieve dll, exe, or other "potentially
unsafe" files.
Robin Hammond
www.enhanceddatasystems.com
"www.microsoft.com" <[email protected]> wrote in message
news:[email protected]...
> How to write a micro to download file at a URL save the file at the local
> PC
>
> Thanks
>
this id the code i use on a dily bases to download files from the internet
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2003 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
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 DownLoadFileFromIntranet(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.
DownLoadFileFromIntranet = URLDownloadToFile(0&, _
sSourceUrl, sLocalFile, _
BINDF_GETNEWESTVERSION, _
0&) = ERROR_SUCCESS
End Function
Sub DownLoadFile()
Dim DownLoadFile As String
Dim sUrl As String
DownLoadFile$ = "c:\test down load.txt"
sUrl$ = "Replace this with full url for file to be downloaded"
If DownLoadFileFromIntranet(sUrl, DownLoadFile) = False Then
do something
else
do something else
end if
End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks