{"title":"File.CreateOutStream(OutStream) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/file/file-createoutstream-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-createoutstream-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-createoutstream-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 an OutStream object for a file.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"File.CreateOutStream(OutStream) Method","slug":"filecreateoutstreamoutstream-method","at":0,"chars":1478},{"level":2,"title":"Syntax","slug":"syntax","at":267,"chars":139},{"level":2,"title":"Parameters","slug":"parameters","at":406,"chars":134},{"level":2,"title":"Example","slug":"example","at":540,"chars":806},{"level":2,"title":"Related information","slug":"related-information","at":1346,"chars":132}],"text":"# File.CreateOutStream(OutStream) Method\n> Version: _Available or changed with runtime version 1.0._\nCreates an OutStream object for a file. This enables you to export or write data to the file.\n> NOTE\n> This method is supported only in Business Central on-premises.\n## Syntax\n```al\n File.CreateOutStream(OutStream: OutStream)\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.\nOutStream\nType: ../outstream/outstream-data-type\n## Example\nThe following example uses the CreateOUTSTREAM method to export data from a table to an XML document. The code uses the file-create-method to create an XML file that is named CustXmlFile.xml in a folder that is named xmlData on drive C. The file-createoutstream-method opens a data stream to output the data from the table to the XML file. The ../xmlport/xmlport-export-method then exports the data and saves it at the specified location. The file-close-method closes the data stream. This example assumes that you have created a folder named xmlData on drive C.\n```al\n var\n    CustXmlFile: File;\n    XmlStream: OutStream;\nbegin\n    CustXmlFile.Create('C:\\XmlData\\Customer.xml');\n    CustXmlFile.CreateOUTSTREAM(XmlStream);\n    XMLPORT.Export(50002, XmlStream);\n    CustXmlFile.Close;\nend;\n\n```\n## Related information\nfile-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}