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

Changes the current directory on the FTP server file system.

procedure ChangeDir(
    const ADirName: string
);
Parameters 
Description 
ADirName 
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: 

 

Code 
Meaning 
500 
Syntax error, command unrecognized. (This may include errors such as command line too long.) 
501 
Syntax error in parameters or arguments. 
502 
Command not implemented. 
421 
Service not available, closing control connection. (This may be a reply to any command if the service knows it must shut down.) 
530 
Not logged in. 
550 
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.

EIdProtocolReplyError 

RetrieveCurrentDir 

ChangeDirUp

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