{"title":"File.Write(Record) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/file/file-write-table-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-write-table-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-write-table-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":"Writes to an MS-DOS encoded file or binary file.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"File.Write(Record) Method","slug":"filewriterecord-method","at":0,"chars":2609},{"level":2,"title":"Syntax","slug":"syntax","at":209,"chars":122},{"level":2,"title":"Parameters","slug":"parameters","at":331,"chars":169},{"level":2,"title":"Remarks","slug":"remarks","at":500,"chars":1165},{"level":2,"title":"Example","slug":"example","at":1665,"chars":812},{"level":2,"title":"Related information","slug":"related-information","at":2477,"chars":132}],"text":"# File.Write(Record) Method\n> Version: _Available or changed with runtime version 1.0._\nWrites to an MS-DOS encoded file or binary file.\n> NOTE\n> This method is supported only in Business Central on-premises.\n## Syntax\n```al\n File.Write(Value: Record)\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.\nValue\nType: ../record/record-data-type\nThe data that you want to write to the file.\n## Remarks\nYou must call the file-textmode-method before you call the Write method.\nIf file-textmode-method is set to true and Value is an integer, then the integer is written as text, followed by a new line character.\nIf Value is a record, each field is separated by a tab character.\nIf file-textmode-method is false and Value is an integer, an integer is written that is four bytes long.\nMS-DOS encoding requires a different character set for each language. MS-DOS text is encoded to the internal Unicode data type by using the system locale language of the computer that is running Dynamics 365 Business Central service. If you write to a file that uses MS-DOS encoding, then you must set the system locale language of the computer that is running Dynamics 365 Business Central service to match the language of the data that you want to write to the file.\nWe recommend that you use the File data type for files that were created in earlier versions of Dynamics 365.\nTo read or write files in Unicode or in other formats, we recommend that you use .NET Framework interoperability and use the System.IO Namespace<https://learn.microsoft.com/dotnet/api/system.io>.\n## Example\nThe following example determines whether the specified file exists. If it exists, 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 closes the file. If the file does not exist, then an error message is displayed. This example assumes that you have created the following file: C:\\\\TestFolder\\\\TestFile.txt.\n```al\nvar\n    FileName: Text;\n    TestFile: File;\n    Rec: Record Customer;\nbegin\n    FileName := 'C:\\TestFolder\\TestFile.txt';\n    if Exists(FileName) then begin\n      TestFile.WriteMode(True);\n      TestFile.Open(FileName);\n      TestFile.Write(Rec);\n      TestFile.Close;\n    end else\n      Message('%1 does not exit.', FileName);\nend;\n```\n## Related information\nfile-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}