cd

Change or get the current directory on the remote server over FTP connection.

Attention: Available only with Twin Activate commercial edition.

Syntax

R = cd(ftpObj)

R = cd(ftpObj, dir)

Inputs

ftpObj
FTP object
Type: FTP object
dir
Directory to change to on the server.
Type: string

Outputs

R
Current directory on the server.
Type: string

Example

Change the directory on the remote server:
% Create the FTP object and get the contents
ftpObj = ftp('ftp://127.0.0.1:60000','user', 'password');
% Get the current path - this is relative to the server address
currentPath = cd(ftpObj)
disp('Contents of the root directory:')
dir(ftpObj)

% Change to the 'Folder1' directory
newPath = cd(ftpObj, 'Folder1')
% Get the contents of 'Folder1'
disp('Contents of ''Folder1'':')
dir(ftpObj)
close(ftpObj);
currentPath = /
Contents of the root directory:
ans = drwxrwxrwx   1 owner    group           0 Feb 19 08:53 Folder1
drwxrwxrwx   1 owner    group           0 Feb 19 08:53 Folder2
-rw-rw-rw-   1 owner    group           0 Feb 19 08:53 file1.txt
-rw-rw-rw-   1 owner    group           0 Feb 19 08:53 file2.txt

newPath = /Folder1
Contents of 'Folder1':
ans = -rw-rw-rw-   1 owner    group           0 Feb 19 08:52 file1_1.txt
-rw-rw-rw-   1 owner    group           0 Feb 19 08:52 file1_2.txt