Download internet file without interference

Download internet file without interference

Postby yury » Mon Jul 14, 2008 4: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:

Code: Select all  Expand view
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
yury
 
Posts: 56
Joined: Wed May 23, 2007 2:01 pm

Re: Download internet file without interference

Postby Patrick Mast » Mon Jul 14, 2008 6: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:
Code: Select all  Expand view
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:
Code: Select all  Expand view
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
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby driessen » Thu Jul 17, 2008 5: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. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Patrick Mast » Thu Jul 17, 2008 5: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:
Code: Select all  Expand view
IF wfReadURL("http://www.test.be/test.txt") # "Error opening"
   ... File is there
ELSE
   ... File is not there
ENDIF


Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby driessen » 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. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Patrick Mast » Fri Jul 18, 2008 4: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
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby driessen » Fri Jul 18, 2008 8:17 am

Patrick,

Sorry, I looked over it.

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby yury » Fri Jul 18, 2008 7:32 pm

Patrick, perfect !

thanks very much

regards
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
yury
 
Posts: 56
Joined: Wed May 23, 2007 2:01 pm

Postby RAMESHBABU » Sun Jul 20, 2008 2:52 am

Hello Mr.Patrick

Code: Select all  Expand view
oConn := TipClientHttp():New(TURL():New(cUrl))


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

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 614
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby Patrick Mast » Sun Jul 20, 2008 9:59 pm

Hello Ramesh,
RAMESHBABU wrote:
Code: Select all  Expand view
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
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby RAMESHBABU » Mon Jul 21, 2008 12:34 am

Mr.Patrick

Thank you very much.

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 614
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India

Postby MOISES » Mon Jul 21, 2008 8:19 am

Patrick,
Is it available for Harbour?
Saludos / Regards,

FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
MOISES
 
Posts: 838
Joined: Wed Aug 22, 2007 10:09 am

Postby Patrick Mast » Mon Jul 21, 2008 4:16 pm

MOISES wrote:Is it available for Harbour?
Yes, I think Harbour did port the TIP library yes.

Patrick
User avatar
Patrick Mast
 
Posts: 246
Joined: Sat Mar 03, 2007 8:42 pm

Postby ShumingWang » Wed Jul 23, 2008 1: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
ShumingWang
 
Posts: 460
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Postby Horizon » Mon Nov 17, 2008 2:33 pm

Hi Patrick,

Code: Select all  Expand view
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.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Rick Lipkin and 91 guests