Click or drag to resize

FSeek3 Function

X#
Set the file pointer to a new position, specifying three strongly-typed arguments.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.21
Syntax
 FUNCTION FSeek3(
	ptrHandle AS IntPtr,
	liOffset AS LONG,
	dwOrigin AS DWORD
) AS LONG
Request Example View Source

Parameters

ptrHandle
Type: IntPtr
The handle of the open file.
liOffset
Type: Long
The number of bytes to move the file pointer from the position defined by dwOrigin.
It can be a positive or negative number.
A positive number moves the pointer forward in the file, and a negative number moves the pointer backward.
dwOrigin
Type: DWord
The same as nOrigin with FSeek(), except required. See FSeek() for details.

Return Value

Type: Long
The new position of the file pointer, relative to the beginning of the file (position 0). (The original position of the file pointer does not matter.)
Remarks
Remarks
The possible values for the origin are:
ConstantSeeks from
FS_ENDEnd-of-file
FS_RELATIVECurrent pointer position
FS_SETBeginning-of-file
Remarks
Tip Tip
The low level File IO functions in the X# runtime are using .Net filestreams in the background.
That means that the file handles returned by FOpen() and FCreate() are not 'normal' file handles, but unique identifiers that are used to find the underlying stream object in a collection of streams in the runtime.
That also means that you can't use file handles for functions such as FRead() and FWrite() that were not created in the X# runtime.
If you want to access the underlying FileStream, then you should call the function FGetStream(IntPtr)
Examples
This example uses the third argument to report the current position of the file pointer in a specified file (same as FTell()):
X#
1FUNCTION FilePos(ptrHandle) AS LONGINT
2    RETURN(FSeek3(ptrHandle, 0, FS_RELATIVE))
See Also