Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old


Writes a file with the given data.

Component Version macOS Windows Linux Server iOS SDK
Files 3.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Files.WriteFile"; Data; FilePath { ; filter } )   More


Parameter Description Example Flags
Data The data to save. Can be text or container. "Hello World"
FilePath The native file path. Something like "/Users/cs/desktop/test.txt" on Mac and "C:\Programs\Data\test.txt" on Windows. Files without path end in the root directory on Mac. "test.txt"
filter Can be base64 to decode text first from base64 encoding. Or can be Hex to decode from hex encoding. "Base64" Optional


Returns "OK" or an error message.


Writes a file with the given data.
You provide either a container value or some text. For text you can optionally define a filter like base64 or Hex.

See also Text.WriteTextFile for writing text files with specific encoding.

See FileDialog functions if you like to show a save dialog to pick a destination for the file path.
If you need to create directory first, please use Files.CreateDirectory function.

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.


Write file with some text:

MBS("Files.WriteFile"; "Hello World"; $Path )

Write file with some text and decode base64:

MBS("Files.WriteFile"; "SGVsbG8gV29ybGQ="; "/Users/cs/Desktop/test.txt"; "base64")

Write container to temp file and launch:

# get temp folder
Set Variable [$TempFolder; Value:MBS( "Folders.SystemTemporary" )]
# and file name from container
Set Variable [$name; Value:MBS( "Path.LastPathComponent"; test::myContainer )]
# add name to folder path
Set Variable [$TempPath; Value:MBS( "Path.AddPathComponent"; $TempFolder; $name )]
# now write temp file
Set Variable [$r; Value:MBS( "Files.WriteFile"; test::myContainer; $TempPath)]
# and launch file
Set Variable [$r; Value:MBS( "Files.LaunchFile"; $TempPath)]

Write PDF to disk:

Set Variable [$path; Value:MBS( "Path.AddPathComponent"; MBS( "Folders.UserDesktop" ); Invoice::Invoice ID & ".pdf" )]
Set Variable [$r; Value:MBS("Files.WriteFile"; Invoice::PDF Output; $path)]

Write DynaPDF Library to disk and use it:

Set Variable [$path; Value:MBS( "Plugin.Path" )]
Set Variable [$folderpath; Value:MBS( "Path.RemoveLastPathComponent"; $path )]
Set Variable [$libPath; Value:MBS( "Path.AddPathComponent"; $folderpath; "dynapdf.dll" )]
Set Variable [$r; Value:MBS( "Files.WriteFile"; test2::DynaPDFContainer; $libPath )]
Set Variable [$r; Value:MBS( "DynaPDF.Initialize"; $libPath )]

See also

Example Databases

Blog Entries

This function is free to use.

Created 18th August 2014, last changed 26th October 2023

Files.Unmount - Folders.Applications