Skip to content

FileMode

FileMode is used to specify the mode in which a file is opened.

attributesdescription
CreateIf the file does not exist, create a new file for writing. If the file already exists, truncate the file and then reopen it. If the file does not exist, Create will create the file.
OpenOpen the file in read-only mode.
OpenOrCreateOpen an existing file; if the file does not exist, create the file. It allows for reading and writing operations on the file.
TruncateOpen and truncate a file.