Whatever message this page gives is out now! Go check it out!

FileSeek

Last update:
May 18, 2026

Description

Seeks the position for read or write operation of an on-disk or in-memory file on the server.

Returns

Returns the file position within a stream where the next file operation occurs.

Category

Function syntax

FileSeek(fileObj, pos)

See also

History

ColdFusion 9: Added this function.

Parameters

Parameter
Description
fileobj
The file object.
pos
The position in a file within a stream where the following read and write operation must occur.

Example

<cfscript> 
 NewFile = FileOpen(ExpandPath(".") & "\test.txt","write","",true); 
 FileSeek(#NewFile#,0); 
 FileWrite(#NewFile#,"Hello World.. This is for FileOpen, FileSeek, FileSkipBytes."); 
 FileClose(#NewFile#); 
 WriteOutput("<br>Opening in Read Mode.<br>"); 
 NewFile = FileOpen(ExpandPath(".") & "\test.txt","read","",true); 
 ReadFile = FileRead(#NewFile#,100); 
 WriteOutput("#ReadFile#<br>"); 
 FileClose(#NewFile#); 
 WriteOutput("<br>Opening in Read-Write Mode.<br>"); 
 NewFile = FileOpen(ExpandPath(".") & "\test.txt","readwrite","",true); 
 FileSeek(#NewFile#,2); 
 FileSkipBytes(#NewFile#,4); 
 FileWrite(#NewFile#,"Earth"); 
 ReadFile = FileRead(#NewFile#,100); 
 WriteOutput("#ToString(ReadFile)#<br>"); 
 FileClose(#NewFile#); 
 </cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page