Topic Path: Symbol Reference > Classes > TIdFTP Class > TIdFTP Methods > ChangeDir Method
TIdFTP.ChangeDir Method

Changes the current directory on the FTP server file system.

procedure ChangeDir(
    const ADirName: string
path desired on the server file system. 

ChangeDir is a procedure used to change the current directory on the FTP server file system to the subdirectory specified in the ADirName parameter. 

ChangeDir sends the FTP CWD command using ADirName as an argument to set the current directory to the specified value. 

RFC 959 indicates that response code 250 is the success response code for the CWD command. Some server implementations (to remain nameless) return the 200 response code to indicate successful completion of the CWD command. Indy will recognize both response codes 200 and 250 as the success response code for the CWD command. 

According to RFC 959, ChangeDir may encounter any of the following error responses in the FTP protocol: 


Syntax error, command unrecognized. (This may include errors such as command line too long.) 
Syntax error in parameters or arguments. 
Command not implemented. 
Service not available, closing control connection. (This may be a reply to any command if the service knows it must shut down.) 
Not logged in. 
Requested action not taken. File unavailable (e.g., file not found, no access). 


When one of these protocol error responses is received, an EIdProtocolReplyError is raised. The ReplyErrorCode for the exception is set to the numeric portion of the protocol response. The Message for the exception is set to the textual part of the protocol response, and may vary based on the exact values returned from the server implementation. 

An an example, if the directory in ADirName does not exist on the server file system, the EIdProtocolReplyError raised will contain 550 in the ReplyErrorCode. 

Use RetrieveCurrentDir to determine the current working directory on the server file system. 

Use ChangeDirUp to set the current directory on the FTP server to the directory one level higher in the file system hierarchy.




Copyright 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.