# File.Exists(Text) Method
> Version: _Available or changed with runtime version 1.0._
Determines whether a file exists.
> NOTE
> This method is supported only in Business Central on-premises.
## Syntax
```al
[Ok := ]  File.Exists(Name: Text)
```
> NOTE
> This method can be invoked without specifying the data type name.
## Parameters
Name
Type: ../text/text-data-type
The name of the file that you want to check. This includes the path. When you enter the path, consider these shortcuts:
 You can omit the drive designation if the file is located on the current drive.
 You can omit the full path if the file is located in the current directory.
 You can enter only the subdirectory name if the file is located in a subdirectory of the current directory.
## Return Value
*[Optional] Ok*
Type: ../boolean/boolean-data-type
true if the server instance has access to the file; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.
## Example
The following example uses the Exists method to determine whether the specified file exists. If the file exists, then the file-writemode-method allows the file to be open for writing. The file-open-method opens the file, the file-writemode-method writes the text "Hello World" to the file, and then the file-close-method method closes the file. If the file does not exist, an error message is displayed. This example assumes that you have created the following file C:\\TestFolder\\TestFile2.txt.
```al
 var
    TestFile: File;
    FileName: Text;
begin
    FileName := 'C:\TestFolder\TestFile2.txt';
    if exists(FileName) then begin
      TestFile.WriteMode(true);
      TestFile.Open(FileName);
      TestFile.Write('Hello World');
      TestFile.Close;
    end else
        Message('%1 does not exist.', FileName);
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-exists-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-exists-method/
