Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples
New in version: 9.0   9.1   9.2   9.3   9.4   9.5   10.0   10.1   10.2   10.3    Statistic  


Writes a file with the given data.

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


Parameter Description Example value
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 Optional
Can be base64 to decode text first from base64 encoding. Or can be Hex to decode from hex encoding.


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.

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

Created 18th August 2014, last changed 6th September 2016

Files.Unmount   -   Folders.Applications

Feedback: Report problem or ask question.

MBS Xojo PDF Plugins