{"title":"File.Len() Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/file/file-len-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/file/file-len-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/file/file-len-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Gets the length of an ASCII or binary file.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":176,"chars":184},{"level":2,"title":"Parameters","slug":"parameters","at":360,"chars":85},{"level":2,"title":"Return Value","slug":"return-value","at":445,"chars":58},{"level":2,"title":"Remarks","slug":"remarks","at":503,"chars":80},{"level":2,"title":"Example","slug":"example","at":583,"chars":1100},{"level":2,"title":"Related information","slug":"related-information","at":1683,"chars":132}],"text":"> Version: _Available or changed with runtime version 1.0._\nGets the length of an ASCII or binary file.\n> NOTE\n> This method is supported only in Business Central on-premises.\n## Syntax\n```al\nLength :=   File.Len()\n```\n> NOTE\n> This method can be invoked using property access syntax.\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nFile\nType: file-data-type\nAn instance of the file-data-type data type.\n## Return Value\nLength\nType: ../integer/integer-data-type\n## Remarks\nThis method is often used with file-pos-method and file-seek-method.\n## Example\nThe following example opens a text file that is named 'C:\\\\TestFolder\\\\TestFile.txt' and contains the text 'Hello World'. The file-seek-method sets a pointer to position 6 in the file. The file-read-method 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 file-seek-method. 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.\n```al\nvar\n    Testfile: File;\n    varString: Text[200];\n    varLength: Integer;\nbegin\n    Testfile.Open('C:\\TestFolder\\TestFile.txt');\n    Testfile.Seek(6);\n    Testfile.Read(varString);\n    varLength := Testfile.LEN;\n    Message('The text is: %1. The length of the file is: %2', varString, varLength);\nend;\n```\n## Related information\nfile-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}