The Internet Transfer control will automatically establish an FTP session the first time you execute an FTP command. Table 11.5 lists the FTP commands for the control.
Table 11.5: FTP Commands for the Internet Transfer Control
FTP Command | Description |
CD dir | Changes the current directory to the specified directory on the remote computer |
CDUP | Changes the current directory to the parent directory on the remote computer |
CLOSE | Closes the connection to the remote computer |
DELETE file | Deletes the specified file on the remote computer |
DIR [dir] | Returns the list of files from the specified directory (use GetChunk to get the information) |
GET file1 file2 | Retrieves the specified file (file1) from the remote computer and saves it as the specified file (file2) on the local computer |
LS [dir] | Same as DIR |
MKDIR dir | Creates the specified directory on the remote computer |
PUT file1 file2 | Sends the specified file (file1) from the local computer and saves it as the specified file (file2) on the remote computer |
PWD | Returns the current directory from the remote computer (use GetChunk to get the information) |
QUIT | Terminates the current user’s session on the remote computer |
RECV file1 file2 | Same as GET |
RENAME file1 file2 | Changes the name of the specified file (file1) to the specified name (file2) on the remote computer |
RMDIR dir | Deletes the specified directory |
SEND file1 file2 | Same as PUT |
SIZE dir | Returns the size of the specified directory (use GetChunk to get the information) |
WARNING: Security, security, security: Just because a command is listed here does not mean it can be used. Your user name and password will determine your level of access to the files on the server, as well as which commands you will be able to execute.
The session will remain active until you explicitly close it with the Quit or Close commands. If you used the Quit command to log on as a different user, then you need to update the values in UserName and Password properties before you issue the next command.
You can send a file to the remote computer by using the PUT command. The PUT command has two parameters: the name of the file on the local computer and the name of the file on the remote computer. Both are required to successfully transfer a file. The SEND command is another name for the PUT command.
The GET command works the same as the PUT command, but it retrieves a file from the remote machine. Two parameters are required for this command also. The first parameter is the name of the remote file, and the second is the name of the local file. Like the PUT command, both parameters are required to successfully transfer the file. The RECV command is a synonym for the GET command.
One of the side effects of a session-oriented protocol like FTP is that the server can remember certain information from one command to the next. So commands like CD, CDUP, and PWD allow you to traverse the directory structure on the remote computer and let you specify filenames relative to the current working directory.
You can also create and delete directories using the MKDIR and RMDIR commands. You can retrieve a list of files using the DIR command. (Note that the LS command is a synonym for the DIR command.) When using the DIR command, you need to use the GetChunk method to retrieve the contents of the directory. The chunk of information returned is merely a list of files in the current directory on the remote system. Each file is listed on a single line with a carriage return/line feed pair between them. No size or other information is returned in this value. (Note that you can also specify the name of a file or directory, and that information will be returned in place of the list of files in the current working directory.)