Skip to content

AddString

Adds a new text file to the repository and returns the created FileInfo.

1
myDocumentFiles.AddString(content: string, name: string, codePage?: number):FileInfo

Parameters

string content
    The content of the file.

string name
    The name of the file.

number codePage optional
    The code page of the string. If not specified, UTF8 encoding is used.

Returns

The created FileInfo.

Examples

Create a tab-delimited text file from XML data

1
2
3
4
5
6
7
8
9
var content = '';

$Xml.SelectAll('Payments/Payment', function (payment) {
    content += payment.Evaluate('Type') + '\t' + payment.Evaluate('Amount') + '\r\n';
});

// UTF-8 by default
var file = $Files.AddString(content, 'PaymentOrder.txt');
$Xml.SetValue('PaymentOrderFile', file.Id);

Create a text file with a specific code page

1
2
// 1254 is the Windows Turkish code page
var file = $Files.AddString('Name;City\r\n', 'export.csv', 1254);

See Also