ChangeFTPDirectory Method
Class: FTP_SERVICE
Description:Change the current directory on the FTP Server
Tries to change the current directory on the FTP Server to the path specified.
=
Object.ChangeFTPDirectory
Parameter
lcNewDir
New remote directory
Type Character
Direction Input
Name of the Path to change the current directory to.
Return value Boolean
Returns .T. if the function successfully changed the current directory on the FTP Server. Returns .F. if the function could not change the directory.
Example
LOCAL loFTP,lcPom #INCLUDE "ftp.h" SET PROCEDURE TO ftp.prg ADDITIVE loFTP=CREATEOBJECT('ftp_service') IF loFTP.OpenInternet("ABONNE", "PWD", "10.10.10.10", "21") IF !loFTP.ChangeFTPDirectory("dowload") ?loFTP.GetExtendedErrorCode(),loFTP.GetExtendedErrorMsg() ENDIF =loFTP.CloseInternet() ENDIF RELEASE PROCEDURE ftp.prg
See also
Expand/Collapse source code of procedure ChangeFTPDirectory Source Code
LPARAMETERS INP lcNewDir
      LOCAL fResult, lcTempDir, llResult
                                    
      IF This.OpenFTPConnection(This.cCurrentDir)     && Open an FTP Handle                  
         llResult = .F.     
         lcTempDir = SPACE(MAX_PATH)                            
                                                    
         =This.BeforeChangeFTPDirectory(@m.lcNewDir)
         fResult = FtpSetCurrentDirectory(This.nConnect_Handle, @m.lcNewDir)
         =This.GetExtendedError()
                                  
         IF m.fResult = 1
            fResult = FtpGetCurrentDirectory(This.nConnect_Handle, @m.lcTempDir, MAX_PATH)
            =This.GetExtendedError()
                                      
            IF m.fResult = 1
               This.cCurrentDir = LEFT(m.lcTempDir,AT(CHR(0),m.lcTempDir)-1)
               llResult = .T.
            ENDIF
         ENDIF
         =This.AfterChangeFTPDirectory(@m.lcNewDir,m.fResult)
                   
         =IIF(This.lMultiOperations,.T.,This.CloseFTPConnection())   && Close FTP Handle
         RETURN m.llResult
      ENDIF           
      RETURN .F.