FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour downloading a specific file
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
downloading a specific file
Posted: Sat Mar 05, 2022 08: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 (fw): Select all Collapse
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: downloading a specific file
Posted: Sat Mar 05, 2022 08:17 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: downloading a specific file
Posted: Sat Mar 05, 2022 10:14 AM
Antonio Linares wrote:Dear Silvio,

https://answers.microsoft.com/en-us/windows/forum/all/where-are-downloaded-files-stored-with-windows-7/d4a0c9c3-af1a-46c8-9287-19681f525956


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 (fw): Select all Collapse
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
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: downloading a specific file
Posted: Sat Mar 05, 2022 07: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 (fw): Select all Collapse
LOCAL cUser := Getenv("USERPROFILE")
LOCAL cDownload := cUser +"\DOWNLOADS"
greeting,

Jimmy

Continue the discussion