|
Onetastic Macro Documentation >
>
>
FileSystem_ReadFromFile FileSystem_ReadFromFile
Reads the contents of the given file in either binary or text mode. If binary mode is used, return type is Binary, otherwise return type is String.
Syntax
Binary|String FileSystem_ReadFromFile(
File|String file,
String mode)
Parameters
- File|String file
- File to read from. This can either be a File object or a String that contains the full path to the file.
- String mode
- Read mode that indicates binary read or the text encoding of the file. Possible values are:
"binary", "text", "utf8", "utf16".
RemarksSee below for the how the file content is read based on the mode parameter:
| Value of mode | Content is read as | Text encoding | Return type |
"binary" | binary | N/A | Binary |
"text" | text | Auto detected as either UTF-8 or UTF-16 | String |
"utf8" | text | UTF-8 | String |
"utf16" | text | UTF-16 | String |
Examples
Copied!
$files = FileSystem_ShowOpenFileDialog(false)
if (Array_Length($files) > 0)
$text = FileSystem_ReadFromFile($files[0], "text")
$binary = FileSystem_ReadFromFile("c:\\temp\\image.png", "binary")
$image = InsertObject(GetCurrentPage(), "Image", -1)
$image.data = $binary
|