CFile Access Modes


The CFile class can access files in binary or text compatibility mode for reading, writing, or appending. The Open method sets the file access using an access mode string that describes all of these options. The table below lists pre-defined file access mode strings, which are the standard names inherited from the C language.

CFile Access Mode Definitions

Mode String

Mode

Open for:

"rt"

Text

Reading

"wt"

Text

Writing

"w+t"

Text

Write with Append

"r+t"

Text

Read and Write

"a+t"

Text

Read and Write with Append

Example

The following script opens a text file for reading and writing, beginning at the end of the file. Note that the mode name is prefixed by the instance of the class, F, and not by the class name:

F = CFile:new()

-- create a new CFile instance

F:Open( sPath, "r+t" )

-- open as text for reading and writing

Related Topics

Open

FileOpen

CFile Class