Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.0   6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3    Statistic  

Container.ReadFile

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 } )

Parameters

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.
"Auto"
filename Optional
If result is container, this defines the file name to use.
"test.txt"

Result

Returns container value or error.

Description

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.

Examples

Read image file:

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

See also

Example Databases


Container.ReadArchive   -   Container.Remove

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins