The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.
LEN Method (File)
Gets the length of an ASCII or binary file.
Length := File.LEN
Use this variable to refer to the file.
Property Value/Return Value
The length of the file in bytes.
The following example opens a text file that is named 'C:\TestFolder\TestFile.txt' and contains the text ‘Hello World’. The SEEK Method (File) sets a pointer to position 6 in the file. The READ Method (File) reads the file and stores the retrieved contents in the varString variable. The LEN method retrieves the length of the file and stores it the varLength variable. The text that is read starts from the position of the pointer, so the text ‘World’ and the length of 12 are displayed in the message box. The length of the file is not affected by the SEEK Method (File). This example assumes that you have created the text file that is named C:\TestFolder\TestFile.txt and contains the text ‘Hello World’. This example requires that you create the following global variables.
Testfile.OPEN('C:\TestFolder\TestFile.txt'); Testfile.SEEK(6); Testfile.READ(varString); varLength := Testfile.LEN; MESSAGE('The text is: %1. The length of the file is: %2', varString, varLength);