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


Reads a file with the given path.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
Container 6.4 Yes Yes Yes Yes Yes
MBS( "Container.ReadFile"; FilePath { ; mode; filename } )   More


Parameter Description Example value
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"
mode Optional
If missing or "auto", the plugin will try to detect type by file name extension.
If filter is "container", the result is returned as a container with a FILE stream inside.
The type can be specific here like PDF, JPEG, TIFF, GIF, BMP or PSD to return as image container. Or "compressed" to return a compressed container.
filename Optional
If result is container, this defines the file name to use.


Returns container value or error.


Reads a file with the given path.
Reads the data in the file and returns as container.
See also Text.ReadTextFile for reading text files with specific encoding.

For reading simple text files, please use Text.ReadTextFile.
See also Files.ReadFile, Files.ReadJPEG, Files.ReadPDF, Files.ReadPNG, Text.ReadTextFile and RichText.ReadFile.

This function is optimized for FM 14 and newer to stream file content when using auto mode. This allows to import up to 4 GB of data in small chunks.

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.


Read image file:

MBS( "Container.ReadFile"; "/Users/cs/Pictures/test.jpg"; "auto")

Read image file with error checking:

# get native path
Set Variable [ $path ; Value: "/Users/cs/Pictures/mond.jpg" ]
# read file
Set Variable [ $content ; Value: MBS( "Container.ReadFile"; $path) ]
# check for error
If [ MBS("IsError") = 0 ]
    Set Field [ Contacts::Photo Container ; $content ]
    Show Custom Dialog [ "Failed to read file." ; $content ]
End If

See also

Example Databases

Blog Entries

Created 6th September 2016, last changed 24th January 2020

Container.ReadArchive   -   Container.ReadImage

Feedback: Report problem or ask question.

MBS Xojo PDF Plugins