Muokkaa

Jaa


File.TextMode([Boolean]) Method

Version: Available or changed with runtime version 1.0.

Sets whether a file should be opened as an ASCII file or a binary file. Gets the current setting of this option for a file.

Note

This method is supported only in Business Central on-premises.

Syntax

[Textmode := ]  File.TextMode([Mode: Boolean])

Note

This method can be invoked using property access syntax.

Note

This method can be invoked without specifying the data type name.

Parameters

File
 Type: File
An instance of the File data type.

[Optional] Mode
 Type: Boolean

Return Value

[Optional] Textmode
 Type: Boolean

Remarks

This method should be used before File.Open is used to open the file. If you use this method on a file that is already open, then an error occurs.

Example

The following example sets the TextMode to true when the file is open for writing. This means the file contents will be written to a text file that is named 'C:\TestFolder\TestFile.txt' by using ASCII characters. The WriteMode Method (File) and the Open Method (File) open the file for writing and the text ‘Hello World’ is written. The Close Method (File) closes the file after the file is written to. This example assumes that you have created a text file that is named C:\TestFolder\TestFile.txt.

var
    TestFile: File;
begin 
    TestFile.TextMode(True);  
    TestFile.WriteMode(True);  
    TestFile.Open('C:\TestFolder\TestFile.txt');  
    TestFile.Write('Hello World');  
    TestFile.Close;  
end;

File Data Type
Get Started with AL
Developing Extensions