# File.CreateTempFile([TextEncoding]) Method
> Version: _Available or changed with runtime version 1.0._
Creates a temporary file. This enables you to save data of any format to a temporary file. This file has a unique name and will be stored in a temporary file folder.
> NOTE
> This method is supported only in Business Central on-premises.
## Syntax
```al
[Ok := ]  File.CreateTempFile([Encoding: TextEncoding])
```
> 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.
*[Optional] Encoding*
Type: ../textencoding/textencoding-option
The encoding that will be used by the stream. The default encoding is MSDos.
## Return Value
*[Optional] Ok*
Type: ../boolean/boolean-data-type
## Remarks
You can use this method together with file-name-method and file-close-method.
## Example
This example creates a temporary file that has the text Hello and then deletes the file by using the File.Close method.
```al
 var
    FileName: File;
begin
    FileName.CreateTempFile;
    FileName.Write('Hello');
    FileName.Close;
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-createtempfile-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-createtempfile-method/
