![]() ![]() | ||
When you open a file with the FileStream class, you specify the file mode you want to use—for example, if you want to create a new file, you use the file mode FileMode.Create. The various possible file modes are part of the FileMode enumeration; you can find the members of this enumeration in Table 13.9.
Member |
Means |
---|---|
Append |
Opens a file and moves to the end of the file (or creates a new file if the specified file doesn't exist). Note that you can only use FileMode.Append with FileAccess.Write. |
Create |
Creates a new file; if the file already exists, it is overwritten. |
CreateNew |
Creates a new file; if the file already exists, an IOException is thrown. |
Open |
Opens an existing file. |
OpenOrCreate |
Open a file if it exists; or create a new file. |
Truncate |
Open an existing file, and truncate it to zero length so you can write over its data. |
![]() ![]() | ||