Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Files.CreateDirectory
Creates a directory.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Files | 2.7 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
(old name: Files.CreateFolder)
Parameters
Parameter | Description | Example |
---|---|---|
Path | Native path to the new directory to be created. | "C:\Test" |
Result
Returns "OK" or error message.
Description
Creates a directory.Returns "OK" if the directory already exists.
This function needs a native path. Please use Path.FileMakerPathToNativePath function in order to convert a FileMaker style path to a native path.
For MacOS & iOS creates folders recursively as needed.
In the Mac world we call it a folder, in the Windows world a directory. This function works cross platform and got the name with Directory years ago.
You can use Files.DeleteFolder to delete a folder with its content.
Changed for plugin version 10.5 to do recursive folder creation on Windows, too.
Examples
Create folder on Desktop:
Set Variable [$folder; Value:MBS( "Folders.UserDesktop" )]
If [IsEmpty(Container Export::Name)]
Set Field [Container Export::Name; "Record " & Get(RecordID)]
End If
Set Variable [$path; Value:MBS( "Path.AddPathComponent"; $folder; Container Export::Name )]
Set Variable [$r; Value:MBS("Files.CreateDirectory"; $path)]
Creates directory and shows error:
Set Variable [$r; Value:MBS("Files.CreateDirectory"; $path)]
If [MBS("IsError")]
Show Custom Dialog ["Failed to create directory"; MBS("Text.RemovePrefix"; $r; "[MBS] ")]
Exit Script []
End If
Create a folder:
MBS( "Files.CreateDirectory"; "/Users/cs/Documents/FolderName" )
Create recursive folder structure on desktop:
MBS( "Files.CreateDirectory"; "C:\\Users\\Christian\\Desktop\\test1\\test2\\test3\\" )
// needs MBS Plugin 10.5 or newer
See also
- Files.Delete
- Files.DeleteFolder
- Folders.UserDesktop
- Folders.UserDocuments
- Folders.UserDownloads
- IsError
- Path.FileMakerPathToNativePath
- Text.RemovePrefix
- Text.WriteTextFile
- WIA.ImageDialog
Release notes
- Version 10.5
- Changed Files.CreateDirectory to create folders recursively on Windows, too.
Example Databases
- CURL/Email/Email Parser and Preview
- CURL/Email/IMAP Email
- DynaPDF/Scan with WIA to PDF
- Files/FileOperation
- Mac and iOS/PDFKit/PDFKit Print Documents
- Utility functions/Split DDR
- Win Only/WIA Scan
Blog Entries
- MBS Plugin Advent calendar: 12 - Files
- Convert Office Files in FileMaker
- Recursive Folder Copy Script
- MBS FileMaker Plugin, version 10.5pr6
- Storing files for download on FileMaker Server with download URLs
- Comparing Base Elements Plugin to MBS FileMaker Plugin
FileMaker Magazin
Created 18th August 2014, last changed 23th October 2020