downloading a specific file

Post Reply
User avatar
Silvio.Falconi
Posts: 7169
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 3 times

downloading a specific file

Post by Silvio.Falconi »

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


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 March-April 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: 7169
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 3 times

Re: downloading a specific file

Post by Silvio.Falconi »



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

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 March-April 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
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

Re: downloading a specific file

Post by Jimmy »

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

LOCAL cUser := Getenv("USERPROFILE")
LOCAL cDownload := cUser +"\DOWNLOADS"
greeting,
Jimmy
Post Reply