fileSeek
Description
Seeks the position for read or write operation of an on-disk or in-memory file on the server.
Categories
Related
History
ColdFusion
9: Added this function.
Syntax
FileSeek(fileObj, pos)
Attributes
| Attribute | Description | Required | Default |
|---|---|---|---|
| fileObj | The file object. | ||
| pos | The position in a file within a stream where the following read and write operation must occur. |
Returns
Returns the file position within
a stream where the next file operation occurs.
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>