File Access Mode
|
Description
|
r
|
Opens the specified file for read only access. Upon opening the file pointer is positioned at the very beginning of the file. If file_access_mode is left out of the open() statement, this is the default access mode.
|
rb
|
Opens the specified file for binary read only access. Upon opening, the file pointer is positioned at the very beginning of the file.
|
r+
|
Opens the specified file for both read and write access. Upon opening, the file pointer is positioned at the very beginning of the file.
|
rb+
|
Opens the specified binary file for both read and write access. Upon opening, the file pointer is positioned at the very beginning of the file.
|
w
|
Opens the specified file for writing only. If the file exists already at the location specified, the existing file is overwritten. If the file does not exist already, the file is created with the name specified.
|
wb
|
Opens the specified binary file for writing only. If the file exists already at the location specified, the existing file is overwritten. If the file does not exist already, the file is created with the name specified.
|
w+
|
Opens the specified file for both reading and writing. If the file exists already at the location specified, the existing file is overwritten. If the file does not exist already, the file is created with the name specified.
|
wb+
|
Opens the specified binary file for both reading and writing. If the file exists already at the location specified, the existing file is overwritten. If the file does not exist already, the file is created with the name specified.
|
a
|
Opens the specified file for appending. If the file exists, the file pointer is positioned at the end of the file and the file is set to append mode, that is, any new data written to the file will be appended (added) to the end of the file. If the specified file does not already exist, then the file is created using the file name specified, the file pointer will be at the beginning of the empty file and the file will be set for writing.
|
ab
|
Opens the specified binary file for appending. If the file exists, the file pointer is positioned at the end of the file and the file is set to append mode, that is, any new data written to the file will be appended (added) to the end of the file. If the specified file does not already exist, then the file is created using the file name specified, the file pointer will be at the beginning of the empty file and the file will be set for writing.
|
a+
|
Opens the specified file for appending and reading. If the file exists, the file pointer is positioned at the end of the file and the file is set to append mode, that is, any new data written to the file will be appended (added) to the end of the file. If the specified file does not already exist, then the file is created using the file name specified, the file pointer will be at the beginning of the empty file and the file will be set for writing.
|
ab+
|
Opens the specified binary file for appending and reading. If the file exists, the file pointer is positioned at the end of the file and the file is set to append mode, that is, any new data written to the file will be appended (added) to the end of the file. If the specified file does not already exist, then the file is created using the file name specified, the file pointer will be at the beginning of the empty file and the file will be set for writing.
|