Skip to main content

TrFile_ExportToFile (function reference)

Troi File Plug-in > Functions reference > TrFile_ExportToFile
Troi File Plug-in for FileMaker Pro


Exports the (binary) contents of a container field or variable to a new file.

SyntaxFunction badge

TrFile_ExportToFile ( switches ; source ; filePath )


switches modifies the behavior of the function
source a container field or variable you want to export the (binary) data of
filePath the destination path you want to export to


Switches can be empty or one or more of the following:

-OverwriteExisting overwrite an existing file without generating an error

Returned Result

Data type returned

Error code


The returned result is an error code. Returned error codes can be:

0 no error the (binary) file was created
$$-50 paramErr parameter error
$$-48 dupFNErr destination file already exists

Originated in

Troi File Plug-in 11.0


FileMaker Pro 16 to FileMaker Pro 2023


This function can also be used on FileMaker Server.


Set Variable [ $ErrorCode ; TrFile_ExportToFile ( "-OverwriteExisting" ; 
                                                   gContainer ; "Mac HD:photo.jpg" ) ]

This will create a file photo.jpg with the contents of the container field. Note that this will overwrite an existing file.

Example 2

Say you want to export the contents of a container field of all records of a found set to disk. We assume that in your FileMaker file the following fields are defined:

  gErrorCode	Global, number
  theContainer	Container

In a script add the following script steps:

Set Variable [ $ErrorCode ; 0 ]
Go to Record/Request/Page [ First ]
    # Build the path:
    Set Variable [ $DestPath; Value: Get ( DocumentsPath ) & theContainer ]
    Set Variable [ $Container ; theContainer ]
    Set Variable [ $ErrorCode ; TrFile_ExportToFile ( "-Unused" ; $Container ; $DestPath ) ]
    Exit Loop If [ Left ( $ErrorCode ; 2 )  = "$$" ) ]
    Go to Record [ Next; Exit after last: On ]
End Loop
Set Field [ gErrorCode ; $ErrorCode ]

Used in example file


Related functionFunction badge


Related topics

Troi File Plug-in online help (overview)

Online Help Page for Troi File Plug-in for 16 to 2023 –> TrFile_ExportToFile (filep4321) 2023-0601 15:19:20