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
System functions
Function syntax
See also
FileCopy, FileDelete, FileExists, FileMove, FileSetAccessMode, FileSetAttribute, FileSkipBytes
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>
|