FileSeek

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.

Function syntax

FileSeek(fileObj, pos)

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>