delete

Deletes a file over an FTP connection.

Attention: Available only with Twin Activate commercial edition.

Syntax

delete(ftpObj, filename)

Inputs

ftpObj
FTP object
Type: FTP object
filename
File to delete. Relative path to the file may also be used.
Type: string

Examples

Delete a file in the root directory:
% Create the FTP object and get the contents
ftpObj = ftp('ftp://127.0.0.1:60000','user', 'password');
disp('Contents of the root directory:')
dir(ftpObj)
% Delete the file 'file1.txt'
delete(ftpObj,'file1.txt')
% Verify that the file has been deleted
disp('Contents of root directory after deleting ''file1.txt'':')
dir(ftpObj)
close(ftpObj);
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

Contents of root directory after deleting 'file1.txt':
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 file2.txt
Delete a file using the relative path:
% Create the FTP object and get the contents of 'Folder1'
ftpObj = ftp('ftp://127.0.0.1:60000','user', 'password');
disp('Contents of ''Folder1'':')
dir(ftpObj,'Folder1');
% Use the relative path to delete 'file1_1.txt'
delete(ftpObj,'Fodler1/file1_1.txt')
% Verify that the file has been deleted
disp('Contents of ''Folder1'' after deleting ''file1_1.txt'':')
dir(ftpObj,'Folder1')
close(ftpObj);
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

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