« Filemaker meeting in … | Home | Mountain Lion wishes?… »

Tip of the day: Move to trash

Sometimes I like to move stuff to the trash on Mac and recycle bin on Windows. And this is how you can do it using our plugins:
  Function MoveToTrash(f as FolderItem) As Boolean
#if TargetMacOS then
dim r as FolderItem
dim n as integer = MacFileOperationMBS.MoveObjectToTrashSync(f, r, _
MacFileOperationMBS.kFSFileOperationDefaultOptions)

if n = 0 then
Return true // OK
end if
#elseif TargetWin32 then
dim w as new WindowsFileCopyMBS

dim flags as integer = w.FileOperationAllowUndo + w.FileOperationNoErrorUI + _
w.FileOperationSilent + w.FileOperationNoConfirmation
if w.FileOperationDelete(f, flags) then
Return true // OK
end if

#endif
End Function
I hope you can use it. The function returns true on success and shows no error messages or confirmation dialogs.
13 06 12 - 19:20