編集

次の方法で共有


File.CreateInStream(InStream) Method

Version: Available or changed with runtime version 1.0.

Creates an InStream object for a file. This enables you to import or read data from the file.

Note

This method is supported only in Business Central on-premises.

Syntax

 File.CreateInStream(InStream: InStream)

Note

This method can be invoked without specifying the data type name.

Parameters

File
 Type: File
An instance of the File data type.

InStream
 Type: InStream

Example

The following example imports data from an XML document to a table. The code uses the Open Method (File) to open the XML document named NewCustomer.xml from a folder named Import on the C drive. The CreateInStream Method (File) creates a data stream to get the data from the XML document into the table. The Import Method (XMLport) then imports, parses the data, and adds it as a record to the table by using an XMLport (50004). The Close Method (File) 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.

 var
    ImportXmlFile: File;
    XmlINStream: InStream;
begin
    ImportXmlFile.Open('C:\Import\NewCustomer.xml');  
    ImportXmlFile.CreateInStream(XmlINStream);  
    XMLPORT.Import(50004, XmlINStream);  
    ImportXmlFile.Close;  
end;

File Data Type
Get Started with AL
Developing Extensions