Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

what VB code will go out to a website and download a file?

Posted on 2005-04-27
3
Medium Priority
?
160 Views
Last Modified: 2010-05-02
I have a website with an .exe file at a certain location.
What VB6 code will go to that site, and download the .exe to the
CURRENT WORKING DIRECTORY and then tell me its done?
0
Comment
Question by:rbend
3 Comments
 
LVL 4

Expert Comment

by:ShelfieldCollege
ID: 13874783
0
 
LVL 29

Accepted Solution

by:
nffvrxqgrcfqvvc earned 120 total points
ID: 13875360
Copy paste the following into Form_Declerations...
'You can also add all the code in Form_Load to a command button instead.

'--CODE BEGINS---
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
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
    Dim lngRetVal As Long
    lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    If lngRetVal = 0 Then DownloadFile = True
End Function


Private Sub Form_Load()
Dim Ssave As String
'Save file as?
Ssave = "c:\savefilename.exe"
'URL location of file?
DownloadFile "http://www.somesite.com/files/filename.exe", Ssave
DoEvents
'Display message when its finished downloading
MsgBox "The file has been downloaded - and saved as:  " & Ssave, vbInformation, "Finished"
End Sub

'---CODE ENDS---

Make sure the site you are pulling the .exe file from allows you directly download from the sites folder rather than having to click a link to be able to download it.
0
 

Author Comment

by:rbend
ID: 14076505
yes this works for me:
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month20 days, 16 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question