{"title":"File.CreateTempFile([TextEncoding]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/file/file-createtempfile-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-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.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/file/file-createtempfile-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":"Creates a temporary file.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"File.CreateTempFile([TextEncoding]) Method","slug":"filecreatetempfiletextencoding-method","at":0,"chars":1263},{"level":2,"title":"Syntax","slug":"syntax","at":343,"chars":151},{"level":2,"title":"Parameters","slug":"parameters","at":494,"chars":226},{"level":2,"title":"Return Value","slug":"return-value","at":720,"chars":67},{"level":2,"title":"Remarks","slug":"remarks","at":787,"chars":89},{"level":2,"title":"Example","slug":"example","at":876,"chars":255},{"level":2,"title":"Related information","slug":"related-information","at":1131,"chars":132}],"text":"# File.CreateTempFile([TextEncoding]) Method\n> Version: _Available or changed with runtime version 1.0._\nCreates 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.\n> NOTE\n> This method is supported only in Business Central on-premises.\n## Syntax\n```al\n[Ok := ]  File.CreateTempFile([Encoding: TextEncoding])\n```\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*[Optional] Encoding*\nType: ../textencoding/textencoding-option\nThe encoding that will be used by the stream. The default encoding is MSDos.\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\n## Remarks\nYou can use this method together with file-name-method and file-close-method.\n## Example\nThis example creates a temporary file that has the text Hello and then deletes the file by using the File.Close method.\n```al\n var\n    FileName: File;\nbegin\n    FileName.CreateTempFile;\n    FileName.Write('Hello');\n    FileName.Close;\nend;\n```\n## Related information\nfile-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}