編集

次の方法で共有


File.Seek(Integer) Method

Version: Available or changed with runtime version 1.0.

Sets a file pointer to a new position in an ASCII or binary file.

Note

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

Syntax

 File.Seek(Position: Integer)

Note

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

Parameters

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

Position
 Type: Integer
The position at which to set the pointer.

Remarks

This method is often used with Pos Method (File) and Len Method (File).

Example

The following example sets a pointer at position 20 in a file and truncates the file at the pointer position. The WriteMode Method (File) enables a file named C:\TestFolder\TestFile.txt to open in write mode. The Seek method sets a pointer at position 20 in the file and then the Trunc Method (File) truncates the contents of the file at the pointer position. This example assumes that you have created the text file C:\TestFolder\TestFile.txt.

 var
    TestFile: File;
begin
    TestFile.WriteMode(True);  
    TestFile.Open('C:\TestFolder\TestFile.txt');  
    TestFile.Seek(20);  
    TestFile.Trunc;  
end;
  

File Data Type
Get Started with AL
Developing Extensions