Skip to content

GetString

Returns the file content as a string.

1
myDocumentFiles.GetString(id: string, encoding?: number):string

Parameters

string id
    The ID of the file.

number encoding optional
    The encoding of the file. Optional. The default is 65001 (UTF-8).

Returns

The file content as a string.

Remarks

This function is used to retrieve text file contents. If the file is binary, consider using Files.GetBase64 to avoid corrupting the file content.

Examples

Read an uploaded CSV file

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
var lines = $Files.GetString($Xml.Evaluate('ImportFile')).split('\n');

lines.forEach(function (line) {
    var columns = line.split(';');

    if (columns.length > 1) {
        $Xml.AppendChild('Rows/Row', function (row) {
            row.SetValue('Code', columns[0]);
            row.SetValue('Name', columns[1]);
        });
    }
});

See Also