FileSeek()

语法

FileSeek(#File, NewPosition.q [, Mode])
概要
Change the read/write pointer position in the file.

参数

#File The file to use.
NewPosition.q The new position relative to the beginning of the file in bytes.
Mode (optional) The seek mode. It can be one of the following values:
  #PB_Absolute: the 'NewPosition' parameter will be an absolute position with the file (default).
  #PB_Relative: the 'NewPosition' parameter will be an offset (positive or negative) relative to the current file pointer position.

返回值

无.

示例


  file$ = OpenFileRequester("Select a file","","Text (.txt)|*.txt|All files (*.*)|*.*",0)
  If file$
    If ReadFile(0, file$)
      length = Lof(0)                       ; read length of file
      FileSeek(0, length - 10)              ; set the file pointer 10 chars from end of file
      Debug "Position: " + Str(Loc(0))      ; show actual file pointer position
      *MemoryID = AllocateMemory(10)        ; allocate the needed memory for 10 bytes
      If *MemoryID
        bytes = ReadData(0, *MemoryID, 10)  ; read this last 10 chars in the file
        Debug PeekS(*MemoryID)
      EndIf
      CloseFile(0)
    EndIf
  EndIf

参阅

Loc(), Lof()

已支持操作系统

所有

<- FileID() - File Index - FlushFileBuffers() ->