FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Downloading from a website
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Downloading from a website
Posted: Fri Apr 30, 2010 03:10 PM

Hello,

Can someone tell me how to download a file (usually an EXE-file) from a website and save it to a folder on my networkdrive automatically?

It might be possible that a username and password are necessary to download the file.

Nevertheless I want to download the file without user intervention.

Thank you very much in advance.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Downloading from a website
Posted: Fri Apr 30, 2010 03:29 PM

Hello Michel,

viewtopic.php?f=3t=17600hilit=updatestart=15#p91979

Best regards,
Otto

&&&

Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
Re: Downloading from a website
Posted: Sat May 01, 2010 12:03 AM

Otto
Will the code you referenced work with Harbour?

Thank you

Harvey
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Downloading from a website
Posted: Mon May 03, 2010 12:27 AM

Hi,

When i don't need work with FTP "(user and password)" I use this function to download:

if ( URLDownloadToFile( 0, "http://www.domain.com/file.exe", "c:\file.exe", 0, 0 ) == 1)
MsgStop("Error: Your download failed !!!","Error in download...")
else
MsgInfo("Download Sucess !!!","Download OK")
endif

DLL Function URLDownloadToFile(pCaller AS LONG, szURL AS STRING, szFileName AS STRING, dwReserved AS LONG, lpfnCB AS LONG) AS LONG PASCAL FROM "URLDownloadToFileA" LIB "urlmon.dll"

Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Downloading from a website
Posted: Mon May 03, 2010 07:33 AM

Hi, Lailton.webmaster,

Thanks a lot for your answer.

I tried it out and I got the message that the downloaded is succeeded, but the download itself does not occur.

Any idea ?

Thanks.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Downloading from a website
Posted: Mon May 03, 2010 09:14 AM

Michel,
have you checked your security setup (firewall, antivirus)?
I think to load “exe” files from the Internet system-admin’s want like.
I would suggest to rename the files.
Best regards,
Otto

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Downloading from a website
Posted: Mon May 03, 2010 10:14 AM
Driessen,
Try this way

Code (fw): Select all Collapse
#include "Fivewin.ch"
#define   DOWN_OK    0
#define   DOWN_ERROR 1
function main()
local urlFILE := "http://www.lailton.com.br/tmp/demo._exe"
local toFILE  := "c:\test\demo2.exe"

 if ( URLDownloadToFile( 0, urlFILE, toFILE, 0, 0 ) == DOWN_OK )
      MsgInfo("Download OK !!!")
 else
      MsgStop("Error: Your download failed !!!","Error in download...")
 endif
return
DLL Function URLDownloadToFile(pCaller AS LONG, szURL AS STRING, szFileName AS STRING, dwReserved AS LONG, lpfnCB AS LONG) AS LONG PASCAL FROM "URLDownloadToFileA" LIB "urlmon.dll"
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Downloading from a website
Posted: Mon May 03, 2010 11:37 AM

Otto,

Thanks. I already checked that.

Lailton.webmaster,

Thanks for your example. It's working fine now.

Can we add something that the user can see the progress of the download ?

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Downloading from a website
Posted: Mon May 03, 2010 12:07 PM

Dear Mr.Michel,

To understand how to display a progress bar while downloading a file from internet, Please refer the topic viewtopic.php?f=3&t=11915&start=20

The sample code is available there posted by Mr.Hakan
Pls. remember to link xHarbour's Tip.Lib

Regards
Anser

Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Downloading from a website
Posted: Mon May 03, 2010 12:16 PM
You can use this way:

Code (fw): Select all Collapse
MsgRun("Downloading...","Wait...",{|| iif( URLDownloadToFile( 0, urlFILE, toFILE, 0, 0 ) == DOWN_OK,Msginfo("Download OK"),MsgStop("Download Failed"))} )


Msdn show about OnProgress, more i dont know how add this feature to use.
URL: http://msdn.microsoft.com/en-us/library/ms775123%28VS.85%29.aspx
Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
Re: Downloading from a website
Posted: Mon May 03, 2010 03:12 PM

Is there similiar code for harbour.

Thank you

Harvey
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Downloading from a website
Posted: Mon May 03, 2010 03:18 PM

I belive that this code work too in Harbour.

Please try use. 8)

Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
Re: Downloading from a website
Posted: Tue May 04, 2010 12:37 AM
I seem to have a problem with the dllDownloadtofile call. Do i need to put a new library in my make script. This has me confused.
DLL Function URLDownloadToFile(pCaller AS LONG, szURL AS STRING, szFileName AS STRING, dwReserved AS LONG, lpfnCB AS LONG) AS LONG PASCAL FROM "URLDownloadToFileA" LIB "urlmon.dll"


Please explain.
Thank you

Harvey
Posts: 603
Joined: Sun May 04, 2008 08:44 PM
Re: Downloading from a website
Posted: Tue May 04, 2010 01:07 AM

Try Add this line

include "Fivewin.ch"

include "dll.ch"

or use xHarbour is the best !!

:D:lol:

Continue the discussion