ColdFusion 9.0 Resources |
FileSeekDescriptionSeeks the position for read or write operation of an on-disk or in-memory file on the server. ReturnsReturns the file position within a stream where the next file operation occurs. CategoryFunction syntaxFileSeek(fileObj, pos) See alsoFileCopy, FileDelete, FileExists, FileMove, FileSetAccessMode, FileSetAttribute, FileSkipBytes HistoryColdFusion 9: Added this function. Parameters
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> |