# File.Name() Method
> Version: _Available or changed with runtime version 1.0._
Gets the name of an ASCII or binary file.
> NOTE
> This method is supported only in Business Central on-premises.
## Syntax
```al
Name :=   File.Name()
```
> 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-data-type
An instance of the file-data-type data type.
## Return Value
Name
Type: ../text/text-data-type
## Remarks
You must use the file-open-method to open the file before you can use this method.
## Example
The 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.
```al
var
    Testfile: File;
    varName: Text;
begin
    TestFile.Open('C:\TestFolder\TestFile.txt');
    varName := TestFile.Name;
    Message('The name of the file is: %1',varName);
end;
```
## Related information
file-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

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. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/file/file-name-method/
