{"title":"File.CreateInStream(InStream) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/file/file-createinstream-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-createinstream-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-createinstream-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 InStream object for a file.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"File.CreateInStream(InStream) Method","slug":"filecreateinstreaminstream-method","at":0,"chars":1573},{"level":2,"title":"Syntax","slug":"syntax","at":265,"chars":136},{"level":2,"title":"Parameters","slug":"parameters","at":401,"chars":131},{"level":2,"title":"Example","slug":"example","at":532,"chars":909},{"level":2,"title":"Related information","slug":"related-information","at":1441,"chars":132}],"text":"# File.CreateInStream(InStream) Method\n> Version: _Available or changed with runtime version 1.0._\nCreates an InStream object for a file. This enables you to import or read data from the file.\n> NOTE\n> This method is supported only in Business Central on-premises.\n## Syntax\n```al\n File.CreateInStream(InStream: InStream)\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.\nInStream\nType: ../instream/instream-data-type\n## Example\nThe following example imports data from an XML document to a table. The code uses the file-open-method to open the XML document named NewCustomer.xml from a folder named Import on the C drive. The file-createinstream-method creates a data stream to get the data from the XML document into the table. The ../xmlport/xmlport-import-method then imports, parses the data, and adds it as a record to the table by using an XMLport \\(50004\\). The file-close-method then closes the data stream. This example assumes that you have created a NewCustomer.xml file in a folder that is named Import on the C drive and you have created an XMLport and given it ID 50004.\n```\n var\n    ImportXmlFile: File;\n    XmlINStream: InStream;\nbegin\n    ImportXmlFile.Open('C:\\Import\\NewCustomer.xml');\n    ImportXmlFile.CreateInStream(XmlINStream);\n    XMLPORT.Import(50004, XmlINStream);\n    ImportXmlFile.Close;\nend;\n\n```\n## Related information\nfile-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}