downloading a specific file

downloading a specific file

Postby Silvio.Falconi » Sat Mar 05, 2022 8:12 am

On windows Seven I have difficulty downloading a specific file directly from a remote url and therefore I have to use this command

Code: Select all  Expand view

IF IsWinNT() .OR. isWin2000() // XP/2000/NT
         WinExec( "rundll32.exe url.dll, FileProtocolHandler " + cUrl, 0 )
      ELSE
         WinExec( "Start " + cUrl, 0 )
      ENDIF
 


Now I would have the problem of locating the downloaded file presumably in the download folder of the window
since I can't force my folder where to download the file
how do i calculate the exact route in windows seven?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6774
Joined: Thu Oct 18, 2012 7:17 pm

Re: downloading a specific file

Postby Antonio Linares » Sat Mar 05, 2022 8:17 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: downloading a specific file

Postby Silvio.Falconi » Sat Mar 05, 2022 10:14 am



I allready Kow it :)

C:\Users\Username\Downloads

but that's not always the case sometimes "Users" and sometimes "Users" even if the windows is in Italian language

and if at the moment of saving the user changes folder ????

the comand

WinExec( "rundll32.exe url.dll, FileProtocolHandler " + cUrl, 0 )
ELSE
WinExec( "Start " + cUrl, 0 )

it doesn't give me the folder where the file was saved

causing problems for the other function that has to load the file to process it


this is because in window seven I cannot use this function GETURLTOFILE(cUrl,cZipFile) because the function gives problems


Code: Select all  Expand view
STATIC FUNCTION GETURLTOFILE( cUrl, cFile, cUsr, cPsw )
    LOCAL lOk := .F.

    LOCAL oHtp, oStr, ex

    DEFAULT cFile := CFILENAME( STRTRAN( cUrl, "/", "\" ) )

    //TRY
        oHtp = CREATEOBJECT( "
Msxml2.XMLHTTP.6.0" )
        oHtp:Open( "
POST", cUrl, .F., cUsr, cPsw )
        oHtp:Send()

        IF oHtp:Status != 200 THEN BREAK
        MemoWrit(cFile,oHtp:ResponseBody)
        //oStr = CREATEOBJECT( "
ADODB.Stream" )
        //oStr:Open()
        //oStr:Type = 1
        //oStr:Write( oHtp:ResponseBody )
        //oStr:SaveToFile( cFile, 2 )
        //oStr:Close()

        lOk = .T.
    //CATCH ex
    //        ? ex:message
    //END

    RETURN lOk


on windows 10 run perfectly, on windows Seven No
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6774
Joined: Thu Oct 18, 2012 7:17 pm

Re: downloading a specific file

Postby Jimmy » Sat Mar 05, 2022 7:32 pm

hi Silvio,
Silvio.Falconi wrote:but that's not always the case sometimes "Users" and sometimes "Users" even if the windows is in Italian language

you can use

Code: Select all  Expand view
LOCAL cUser := Getenv("USERPROFILE")
LOCAL cDownload := cUser +"\DOWNLOADS"
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1586
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 76 guests