| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Changes the position of the file pointer.
FSeek( <nFileHandle>, <nBytes>, [<nOrigin>] ) --> nPosition
Start positions for moving the file pointer
| Constant | Value | Description |
|---|---|---|
| FS_SET *) | 0 | Start at the beginning of the file |
| FS_RELATIVE | 1 | Start at the current file pointer position |
| FS_END | 2 | Start at the end of the file |
| *) default | ||
The function returns a numeric value. It is the new position of the file pointer, counted from the beginning of the file (position 0).
The low-level file function FSeek() moves the file pointer of an open file to a new position, without reading the contents of the file. The file pointer can be moved forwards (positive <nBytes>) and backwards (negative <nBytes>). It is not possible, however, to move the file pointer outside the boundaries of a file.
| See also: | FClose(), FCreate(), FError(), FOpen(), FRead(), FReadStr(), FWrite(), HB_F_Eof() |
| Category: | File functions , Low level file functions |
| Header: | FileIO.ch |
| Source: | rtl\philes.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example implements the user-defined function FSize()
// which determines the size of a file using FSeek()
#include "FileIO.ch"
PROCEDURE Main
LOCAL cFile := "MyFile.txt"
? FSize( cFile )
RETURN
FUNCTION FSize( cFile )
LOCAL nHandle := FOpen( cFile )
LOCAL nSize := -1
IF FError() == 0
nSize := FSeek( nHandle, 0, FS_END )
FClose( nHandle )
ENDIF
RETURN nSize
http://www.xHarbour.com