borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Oracle Parameter Problem becaz of Driver Spcific Code)Next Topic (Msgbox (ASP - VBscript)) New Topic New Poll Post Reply
AndreaVB Forum : Internet Applications : Download a File
Poster Message
~Bean~
Level: VB Guru


Registered: 07-04-2003
Posts: 488

icon Download a File

I need a simple function that will download a file from a URL and save on the users computer...as little overhead as possible would be best...

____________________________
Eggheads unite! You have nothing to lose but your yolks.

11-11-2003 at 08:15 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
Lycaon
Level: Guest

icon Re: Download a File

Try this.  No progress or anything but it does everything seamlessly and simply.

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()
    DownloadFile "http://www.allapi.net", "c:\allapi.htm"
End Sub


I'm pretty sure this is a synchronous download, so I wouldn't go about downloading a huge file with it or anything.  A custom class utilizing winsock would be handy.

29-06-2004 at 06:18 PM
| Quote Reply
AndreaVB Forum : Internet Applications : Download a File
Previous Topic (Oracle Parameter Problem becaz of Driver Spcific Code)Next Topic (Msgbox (ASP - VBscript)) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder