file delete, file delete all, file delete silently
These functions delete specified files and come in following flavors:
file delete will assert an exception if file cannot be deleted (e.g. file not found, locked, access restrictions, etc.) Execution will stop immediately.
file delete silently will delete the files until a first failure is encountered. In this case, the applicable one of the short error messages on directories and files
will be returned. If no errors have been encountered, "OK" will be returned.
file delete all tries to delete al files and skips the ones which cannot be created. Here, the number of successfully deleted files will be returned.
Indirect parameter passing is enabled.
Wildcards are not supported here
Min 0
No. | Type | Description |
---|---|---|
1, etc. input |
set or string | file name(s) Specify file name. Add path name in front if needed. With indirect parameter passing enabled, the files to delete can also be provided in one set. Example: file delete( { file1.txt, file.txt, .. } ); |
Type | Description |
---|---|
numeral or string | Feedback file delete: Always "OK", because all errors cause exceptions. |
File not found
File locked by another application
File not accessible
Attempting to delete a directory
file copy ( {3 : Example_Program.b4p}, { Test123.txt, Test456.txt, Test789.txt } );
print( file delete all ( Test123.txt, TestXXX.txt, Test456.txt ), " / " ); // Returns 2
print( file delete ( Test789.txt ), " / " ); // Returns OK
echo( file delete silently ( Test789.txt )); // Returns "File not found"
files[] = { Test123.txt, Test456.txt, Test789.txt };
file copy ( {3 : Example_Program.b4p}, files[] );
echo( file delete all ( files[] ) ); // Returns 3
2 / OK / File not Found
3
directory delete ... Functions
file delete multiple/recursive ... Functions