Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Files.Delete
Deletes a file directly without moving it to trash.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Files | 3.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
Path | The native file path to the file to be deleted. | "/Users/John/Desktop/test.txt" |
Result
Returns OK or error message.
Description
Deletes a file directly without moving it to trash.Works also for directories and can easily remove whole directory hierarchies! Be careful and make backups.
Use Files.MoveToTrash to move files to trash which is often better as it allows users to undo the operation. Also Files.MoveToTrash usually works on files in use.
It is possible that the OS decides to not delete the file and fail (e.g. due to permission errors).
Version 6.3 and newer support deleting a list of files. So you can pass a list of paths instead of just one. Stops at the first error.
Warning: If you pass path to a folder hierarchy, the whole folder hierarchy gets deleted!
On Windows you can't delete/move an open file.
This function requires a native path. Use Path.FileMakerPathToNativePath to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use FileDialog functions.
For Server be aware that server has limited permissions and may not be able to access all files on a computer.
Examples
Delete a file on desktop on Mac:
$r = MBS("Files.Delete"; "/Users/cs/Desktop/testing.fp7")
Delete a file on desktop on Windows:
$r = MBS("Files.Delete"; "C:\Users\Christian\Desktop\testing.fp7")
Delete two files:
MBS("Files.Delete"; "/Users/cs/Desktop/test1.txt¶/Users/cs/Desktop/test2.txt")
Delete two files on Windows:
MBS("Files.Delete"; "C:\Users\Christian\Desktop\test1.txt¶C:\Users\Christian\Desktop\test2.txt")
Delete FileMaker license on macOS:
Set Variable [ $result; Value:
MBS( "Files.Delete"; "/Users/Shared/FileMaker/FileMaker Pro/19.0/LicenseData") &
MBS( "Files.Delete"; "/Users/Shared/FileMaker/FileMaker Pro/19.0/LicenseCert.fmcert")]
Delete FileMaker license on Windows:
Set Variable [ $result; Value:
MBS( "Files.Delete"; "C:\ProgramData\FileMaker\FileMaker Pro\19.0\LicenseData") &
MBS( "Files.Delete"; "C:\ProgramData\FileMaker\FileMaker Pro\19.0\LicenseCert.fmcert")]
See also
- Files.CreateDirectory
- Files.MoveToTrash
- Icon.GetIconWithQuickLook
- ImageCapture.ImagePaths
- ImageCapture.RequestScan
- MongoDB.SetSSLOptions
- Path.FileMakerPathToNativePath
- Plugin.LimitFunction
- Plugin.SetFunctions
- QLPreviewPanel.SavedFiles
Release notes
- Version 13.3
- Added Files.DeleteLater function.
- Version 13.0
- Changed Files.DeleteFolder for Linux to do recursive deletion.
- Version 9.2
- Added check to Files.Delete to prevent you using paths ending in // or \\, which may unexpectedly delete a whole folder.
Example Databases
- Containers/Create Container Preview
- Mac and iOS/PDFKit/PDFKit Print Documents
- Mac only/ImageCapture/ImageCapture
Blog Entries
- MBS Plugin Advent calendar: 12 - Files
- Convert Office Files in FileMaker
- Query MBS Version from plugin in container
- FileMaker 18 File Script Steps vs. BinaryFile functions
- Comparing Base Elements Plugin to MBS FileMaker Plugin
- FileMaker Server Security and plugins
- MBS FileMaker Plugin, version 6.4pr9
- ImageCapture functions for Mac OS X
- MBS FileMaker Plugin 6.3 for OS X/Windows
- Shared FileMaker Server Hosting and Plugin Security
FileMaker Magazin
This function checks for a license.
Created 18th August 2014, last changed 15th November 2022