Reads a complete file in binary mode. Returns the data contained in the file.
Syntax 1
INVOKE USFile.ReadBinaryFile WITH
SELECT USFile.alias
The required alias must be the alias that was associated with the file to be read when the file was opened by calling the USFile.Open method.
Alias in this syntax must be preceded by the prefix "USFile." (ending in a full stop), which is a hard-coded string. Both prefix and alias are case-insensitive.
For more details, see the "Calling USFile.ReadBinaryFile with an alias" section below.
Syntax 2
INVOKE USFile.ReadBinaryFile WITH
SELECT filepath
The required filepath is the name of the file to read. This name is allowed to contain environment variables.
For more details, see the "Calling USFile.ReadBinaryFile with a filepath" section below.
Examples
INVOKE USFile.ReadBinaryFile WITH
SELECT 'USFile.MyOverview'
UPDATE tours_backup
SET tours_pdf = USFile.ReadBinaryFile( 'USFile.MyOverview' )
WHERE id = 1
UPDATE tours_backup
SET tours_pdf = USFile.ReadBinaryFile( '%TEMP%\ToursOverviewFile.pdf' )
WHERE id = 1
Calling USFile.ReadBinaryFile with an alias (Syntax 1 in this help topic) is successful only if you have first called "USFile.Open()" in READ mode. At that occasion, you must have associated a file on the file system with the alias.
Only the FIRST time you call USFile.ReadBinaryFile with the alias is it possible to get file contents as a return value. Second and subsequent calls will return the NULL value. To get another successful read action, you must first close the file by calling USFile.Close() and re-open it by calling USFile.Open(). This contrasts with calling the method with a filepath instead of an alias (next section).
|
To call USFile.ReadBinaryFile with a filepath (Syntax 2 in this help topic), you do not first open a file connection with "USFile.Open()". If you call USFile.Open() first, the alias connected with the file at that time is ignored by USFile.ReadBinaryFile(), which will return the file contents regardless of the alias or the open or closed connection.
Each time you call USFile.ReadBinaryFile with the filepath, you get file contents as a return value. This contrasts with calling the method with an alias instead of a filepath (previous section).
|
See Also
USFile.ReadLine
USFile.ReadTextFile
USFile Internal Component
|