FC_DeleteDirFile - General Information
|
Type: |
Function |
|
Available as of: |
SystemInterface_1.34.1.0 |
|
Support for: |
- |
|
Versions: |
Current version |
Delete a directory including the subdirectories and files, delete individual files/directories or delete files with wildcards.
This function deletes the directory (including the subdirectories and files) or file with the name that is transferred in i_sSource.
i_sSource can contain the name of a file, a directory or of a search filter with wildcard. Consider that it has to be a directory and not a device name.
FC_DeleteDirFile( "usb2msd:0" ) would try to delete the "Directory" "usb2msd:0", which would lead to an error. If the complete content of a device has to be deleted, then it has to be done with one wildcard:
FC_DeleteDirFile( "usb2msd:0/*" ).
|
Command |
Meaning |
|---|---|
|
"Directory/file.txt" |
Valid, deletes the file "file.txt" in the directory "Directory" on the flash disk |
|
"Directory" |
Valid, deletes the directory and the containing subdirectories and files |
|
"*.c" |
Valid, deletes the files with the ending ".c" in the standard directory, not in the subdirectories. |
|
"usb2msd:1/file.*""usb2msd:1/file.*" |
Valid, deletes the files in the top directory of the USB device, the ones that are named with "file." |
|
"*a/*.c" |
Invalid |
|
Input |
Data type |
Description |
|---|---|---|
|
i_sSource |
STRING[1023] |
Name of the directory or the files, or the search mask |
|
Data type |
Description |
|---|---|
|
DINT |
0: The deletion was successful -1: Error when deleting -5: the attempt is made to try to delete a system file => nothing is deleted -318: invalid transfer parameter (at least one file/directory has to be deleted with it) |
Requirement
The directory "ide0:/Backup" is supposed to be deleted.
Declaration
PROGRAM ESystemDirSize
VAR
diStatus : DINT := 0;
END_VAR
Program
diStatus := FC_DeleteDirFile ( 'ide0:/Backup' );
Result
If "diStatus = 0", then the directory was deleted successfully.
NOTE: In this case, you could call up "FC_DeleteDirFile ( 'Backup/' )" too and the result would be the same. But if you want to delete a directory on another flash disk, not the internal flash disk (USB device, RAM disk), then add the device name in the path or else the resolution is not possible.