FileSeek()

Syntax

FileSeek(#File, NewPosition.q)
Description
Change the read/write pointer position in the #File. The parameter 'NewPosition' must be given in Bytes.

Example:


  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

Supported OS

All

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