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  


Type: File

Use this variable to refer to the file.

Property Value/Return Value

Type: Integer

The length of the file in bytes.


This method is often used with POS Method (File) and SEEK Method (File).


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.

Variable name DataType Length
Testfile File Not applicable
varString Text 200
varLength Integer Not applicable
varLength := Testfile.LEN;  
MESSAGE('The text is: %1. The length of the file is: %2', varString, varLength);  

See Also

File Data Type