TrFile_MoveToTrash |
Moves a file or folder to the trash bin (recycle bin).
Syntax
TrFile_MoveToTrash( switches ; sourcePath )
Parameters
| switches | not used, reserved for future use. Leave blank or put "-Unused" |
| sourcePath | the path to the file or folder you want to move to the trash |
Returned Result
Data type returned
Error code
Result
The returned result is an error code. An error always starts with 2 dollars, followed by the error code. You should always check for errors. Returned error codes can be:
| 0 | no error | The item was moved to the trash |
| $$-43 | fnfErr | Source file or folder was not found |
| $$-1426 | errFSOperationNotSupported | This kind of item can’t be moved to the trash |
| $$-4414 | kErrVolumeHasNoTrash | This volume does not support a trash |
Other errors may be returned.
Originated in
Troi File Plug-in 18.0
Compatibility
FileMaker Pro 19 to FileMaker Pro 26
Considerations
The file or folder is not deleted but is moved to the trash. The items will be deleted when the user empties the trash.
On Windows the Trash is called Recycle Bin. On macOS the trash can also be called Bin.
You can’t move a volume (hard disk) to the trash, in this case the function returns error code $$-1426 (errFSOperationNotSupported).
Quite a few external volumes or network disks don’t support moving items into the trash. In this case, if you try to move a file or folder into the trash, the plug-in will return error code $$-4414 (kErrVolumeHasNoTrash). You can then opt for deleting the item directly, with the TrFile_DeleteFile or TrFile_DeleteFolder function.
Example
Set Variable [ $ErrorCode ; TrFile_MoveToTrash ( "-Unused" ; "D:\Report2016.pdf" ) ]
This will move the file Report2016.pdf to the trash. This file will be deleted if the trash is emptied.
Example 2
Set Variable [ $ErrorCode ; TrFile_MoveToTrash ( "-Unused" ;
"/Mac HD/Users/ad/Documents/My Temp Folder" ) ]
This will move the folder My Temp Folder (and its contents) to the trash.
Used in example file
FileManipulation.fmp12
Related functions
| TrFile_DeleteFile |
| TrFile_DeleteFolder |
Related script step
| Move To Trash |
Related topics
Troi File Plug-in online help (overview)