Hello,
I need to create an FWH application that automatically downloads a file from a website so it can be processed. Does anyone have an example that they can share?
Thank you,
Hello,
I need to create an FWH application that automatically downloads a file from a website so it can be processed. Does anyone have an example that they can share?
Thank you,
FUNCTION GETURLTOFILE( cUrl, cFile )
LOCAL lOk := .F.
LOCAL oCli
TRY
oCli = TIPClientHttp():New( cUrl )
IF EMPTY( oCli ); BREAK; ENDIF
oCli:nConnTimeout = -1
IF !oCli:Open(); BREAK; ENDIF
DEFAULT cFile := oCli:oUrl:cFile
IF !oCli:ReadToFile( cFile ); BREAK; ENDIF
lOk = !EMPTY( oCli:cReply ) .AND. "OK" $ UPPER( oCli:cReply )
IF !lOk; FERASE( cFile ); ENDIF
CATCH
END
IF !EMPTY( oCli ); oCli:Close(); ENDIF
RETURN lOkIf you like some sort of auto-update routine http://bielsys.blogspot.com/ is a useful reference too (listed at http://wiki.fivetechsoft.com/doku.php?i ... _resources )
Thank you Enrico, that is what I was look for! I appreciate you help!
TRY
  MsgRun("Downloading ...","One moment please ...",{||IF(URLDownloadToFile(0,"http://www.test.be/test.exe","C:\test.exe",0,0 ) == 0,UpdDown:=0,UpdDown:=1)})
CATCH
  // function in case the file is not found or no internet connection
ENDDLL 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"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
Thank you Michel!