{"title":"File.Name() Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/file/file-name-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-name-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-name-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 name of an ASCII or binary file.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":2,"title":"Syntax","slug":"syntax","at":174,"chars":183},{"level":2,"title":"Parameters","slug":"parameters","at":357,"chars":85},{"level":2,"title":"Return Value","slug":"return-value","at":442,"chars":50},{"level":2,"title":"Remarks","slug":"remarks","at":492,"chars":94},{"level":2,"title":"Example","slug":"example","at":586,"chars":543},{"level":2,"title":"Related information","slug":"related-information","at":1129,"chars":132}],"text":"> Version: _Available or changed with runtime version 1.0._\nGets the name of an ASCII or binary file.\n> NOTE\n> This method is supported only in Business Central on-premises.\n## Syntax\n```al\nName :=   File.Name()\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\nName\nType: ../text/text-data-type\n## Remarks\nYou must use the file-open-method to open the file before you can use this method.\n## Example\nThe following example opens a text file that is named C:\\\\TestFolder\\\\TestFile.txt. The file-name-method retrieves the name and path of the text file and stores it in the varName variable. The value in the variable is displayed in a message box. This example assumes that you have created a text file named C:\\\\TestFolder\\\\TestFile.txt.\n```al\nvar\n    Testfile: File;\n    varName: Text;\nbegin\n    TestFile.Open('C:\\TestFolder\\TestFile.txt');\n    varName := TestFile.Name;\n    Message('The name of the file is: %1',varName);\nend;\n```\n## Related information\nfile-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}