The FileMode enum defines string constants used in the fileMode parameter of the open() and openAsync() methods of the FileStream class. The fileMode parameter of these methods determines the capabilities available to the FileStream object once the file is opened.

The following capabilities are available, in various combinations, based on the fileMode parameter value specified in the open method:

  • Reading — The FileStream object can read data from the file.
  • Writing — The FileStream object can write data to the file.
  • Creating — The FileStream object creates a nonexistent file upon opening.
  • Truncate upon opening — Data in the file is deleted upon opening (before any data is written).
  • Append written data — Data is always written to the end of the file (when any write method is called).

See also:

Variables

@:value(cast "append")@:impl@:enuminlineread onlyAPPEND:String = cast "append"

Used for a file to be opened in write mode, with all written data appended to the end of the file. Upon opening, any nonexistent file is created.

@:value(cast "read")@:impl@:enuminlineread onlyREAD:String = cast "read"

Used for a file to be opened in read-only mode. The file must exist (missing files are not created).

@:value(cast "update")@:impl@:enuminlineread onlyUPDATE:String = cast "update"

Used for a file to be opened in read/write mode. Upon opening, any nonexistent file is created.

@:value(cast "write")@:impl@:enuminlineread onlyWRITE:String = cast "write"

Used for a file to be opened in write-only mode. Upon opening, any nonexistent file is created, and any existing file is truncated (its data is deleted).