FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Download internet file without interference
Posts: 56
Joined: Wed May 23, 2007 02:01 PM
Download internet file without interference
Posted: Mon Jul 14, 2008 04:35 PM
Hi everyone,

How can I download a file in "http:\\200.150.20.14\f_080714.xml"
and save the same in folder "f:\Sistem\xml\" without interference of user ?

I am using:

cLink = "http:\\200.150.20.14\f_080714.xml"

ShellExecute(GetActiveWindow(),nil,cLink,"","",5)


It´s working, but the user need click in save button and choice the folder...

I would like do this automatically...

Many thanks

Regards
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
Posts: 246
Joined: Sat Mar 03, 2007 08:42 PM
Re: Download internet file without interference
Posted: Mon Jul 14, 2008 06:38 PM
yury wrote:How can I download a file in "http:\\200.150.20.14\f_080714.xml" and save the same in folder "f:\Sistem\xml" without interference of user ? I am using:
cLink = "http:\\200.150.20.14\f_080714.xml"
ShellExecute(GetActiveWindow(),nil,cLink,"","",5)
It´s working, but the user need click in save button and choice the folder... I would like do this automatically...


I use this:
FUNCTION wfReadURL(cUrl)
  LOCAL cPageContent:="Error: " + cUrl + " not found or timed out."
  LOCAL oConn
  
  IF Upper(Left(cUrl,4))#"HTTP"
     cUrl:="http://"+cUrl
  ENDIF
  
  TRY
  
   oConn := TipClientHttp():New(TURL():New(cUrl))
   oConn:nConnTimeout := 20000

   IF oConn:Open(cURL)
      cPageContent := oConn:ReadAll()
      oConn:Close()
   ENDIF
   
  CATCH
   cPageContent:="Error opening " + cUrl
   
  END
  
RETURN cPageContent


//================================================================================


FUNCTION wfSaveURL(cUrl,cSaveAs)

  LOCAL cPageContent:=wfReadURL(cUrl)
  LOCAL lReturn:=.T.
  
  IF cPageContent="Error:"
     lReturn:=.F.
  ELSE
     MemoWrite(cSaveAs,cPageContent)
     IF !File(cSaveAs)
        lReturn:=.T.
     ENDIF   
  ENDIF
  
RETURN lReturn


Patrick
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Download internet file without interference
Posted: Thu Jul 17, 2008 05:46 PM

Patrick,

This is a topic which I am interested to.

Is there a possibility to check if a file exist on internet ?

For instance : can I check the existance of a file called :

http://www.test.be/test.txt ?

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: 246
Joined: Sat Mar 03, 2007 08:42 PM
Download internet file without interference
Posted: Thu Jul 17, 2008 05:49 PM
driessen wrote:This is a topic which I am interested to. Is there a possibility to check if a file exist on internet ?

For instance : can I check the existance of a file called :
http://www.test.be/test.txt ?


Sure:
IF wfReadURL("http://www.test.be/test.txt") # "Error opening"
   ... File is there
ELSE
   ... File is not there
ENDIF


Patrick
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Download internet file without interference
Posted: Thu Jul 17, 2008 10:00 PM

Patrick,

Thanks for your answer.

I tried it out but I got an error "unresolved external symbol _HB_FUN_WFREADURL"

What now ?

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: 246
Joined: Sat Mar 03, 2007 08:42 PM
Download internet file without interference
Posted: Fri Jul 18, 2008 04:10 AM
driessen wrote:Thanks for your answer. I tried it out but I got an error "unresolved external symbol _HB_FUN_WFREADURL". What now ?
Comon :-)
The wfReadURL() function is above in this thread :-)

Patrick
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Download internet file without interference
Posted: Fri Jul 18, 2008 08:17 AM

Patrick,

Sorry, I looked over it.

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: 56
Joined: Wed May 23, 2007 02:01 PM
Download internet file without interference
Posted: Fri Jul 18, 2008 07:32 PM

Patrick, perfect !

thanks very much

regards

Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM
Download internet file without interference
Posted: Sun Jul 20, 2008 02:52 AM
Hello Mr.Patrick

oConn := TipClientHttp():New(TURL():New(cUrl))


Please let me know TipClientHttp() and TURL() functions are available in which lib ?

- Ramesh Babu P
Posts: 246
Joined: Sat Mar 03, 2007 08:42 PM
Download internet file without interference
Posted: Sun Jul 20, 2008 09:59 PM
Hello Ramesh,
RAMESHBABU wrote:
oConn := TipClientHttp():New(TURL():New(cUrl))
Please let me know TipClientHttp() and TURL() functions are available in which lib ?

You need to include TIP.LIB

Patrick
Posts: 654
Joined: Fri Oct 21, 2005 05:54 AM
Download internet file without interference
Posted: Mon Jul 21, 2008 12:34 AM

Mr.Patrick

Thank you very much.

  • Ramesh Babu P
Posts: 838
Joined: Wed Aug 22, 2007 10:09 AM
Download internet file without interference
Posted: Mon Jul 21, 2008 08:19 AM

Patrick,
Is it available for Harbour?

Saludos / Regards,



FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
Posts: 246
Joined: Sat Mar 03, 2007 08:42 PM
Download internet file without interference
Posted: Mon Jul 21, 2008 04:16 PM
MOISES wrote:Is it available for Harbour?
Yes, I think Harbour did port the TIP library yes.

Patrick
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Download internet file without interference
Posted: Wed Jul 23, 2008 01:15 AM

hLib = LOADLIBRARY( "urlmon.dll")
if URLDownloadToFile( 0, "www.myweb.com/path/my.exe", "d:\downloadtopath\my.exe", 0, 0 ) == 0

    Else 
       MsgStop("Not download", "Stop" )
       exit

EndIf
FREELIBRARY( hLib )

DLL32 FUNCTION URLDownloadToFile(pCaller AS LONG,szURL AS STRING, szFileName AS STRING, dwReserved AS LONG, lpfnCB AS LONG);
AS LONG PASCAL;
FROM "URLDownloadToFileA";
LIB hlib

Regards!
Shuming Wang

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Download internet file without interference
Posted: Mon Nov 17, 2008 02:33 PM
Hi Patrick,

IF oConn:Open(cURL) 
      cPageContent := oConn:ReadAll() 
      oConn:Close() 
   ENDIF


Is it possible to show progress bar (for example in message bar) while reading at ReadAll() method?

I download big files from www. Users confuse if there is a problem or not.

Thanks,
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06