mkdir

Create a new directory in a server over FTP connection.

Attention: Available only with Twin Activate commercial edition.

Syntax

[R, msg] = mkdir(ftpObj, dirname)

[R, msg] = mkdir(ftpObj, parentdir, dirname)

Inputs

ftpObj
FTP object
Type: FTP object
dirname
Name of the new directory.
Type: string
parentdir
Name of parent directory within which to create newdir.
Type: string

Outputs

R
Returns 1 if successful; returns 0 if not successful.
msg
Returns an error message if the command is not succcessful.

Examples

Create a new directory in the remote location:
% Create the FTP object
ftpObj = ftp('ftp://127.0.0.1:60000','user', 'password');
% Create a new directory called 'MyNewDirectory'
mkdir(ftpObj,'MyNewDirectory');
% Check that the directory is created in the remote location
disp('Contents of the remote root directory:')
dir(ftpObj)
close(ftpObj);
Contents of the remote root directory:
ans = drwxrwxrwx   1 owner    group           0 Feb 19 10:00 Folder1
drwxrwxrwx   1 owner    group           0 Feb 20 09:36 Folder2
drwxrwxrwx   1 owner    group           0 Feb 20 10:10 MyNewDirectory
-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
Create a new directory in the given directory:
% Create the FTP object
ftpObj = ftp('ftp://127.0.0.1:60000','user', 'password');
% Create a new directory called 'MyNewDirectory' inside 'Folder1'
mkdir(ftpObj,'Folder1', 'MyNewDirectory');
% Check that the directory is created in the remote location
disp('Contents of ''Folder1'':')
dir(ftpObj, 'Folder1')
% Create a new directory passing a relative path
mkdir(ftpObj,'Folder1/MyNewDirectory/NewDirectory');
% Check that the directory is created in the remote location
disp('Contents of ''Folder1/MyNewDirectory'':')
dir(ftpObj, 'Folder1/MyNewDirectory')
close(ftpObj);
Contents of 'Folder1':
ans = drwxrwxrwx   1 owner    group           0 Feb 20 10:15 MyNewDirectory
-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
Contents of 'Folder1/MyNewDirectory':
ans = drwxrwxrwx   1 owner    group           0 Feb 20 10:15 NewDirectory