Advertisement
Advertisement
File Modes | Description |
---|---|
FileMode.Open | Opens an existing file and FileNotFoundException exception is thrown if the file does not exist. |
FileMode.OpenOrCreate | Opens an existing file. If the file is not found, a new file is created. |
FileMode.Create | Creates a new file and any existing file with the same name is overwritten. |
FileMode.CreateNew | Creates a new file and if there is already an existing file with the same name then an IOException is thrown. |
FileMode.Truncate | Opens an existing file and truncates its size to zero bytes. If the file does not exist, the FileNotFoundException exception is thrown. |
FileMode.Append | Opens an existing file in an append mode and seeks to the end of the file. A new file is created, if the searched file doesn't exist.
|
FileAccess Modes | Description |
---|---|
FileAccess.Read | This mode gives us the read access to the file, so that data can be read from the file. This FileAccess allows us to read the read-only files i.e. files that we are not allowed to write to. |
FileAccess.Write | This mode gives us the write access to the file, so that we can write data to the file. This FileAccess allows us to write to the write-only files i.e. files that we are now allowed to read from. |
FileAccess.ReadWrite | This mode gives us the read and write access to the file, so that we can read and write data to the file. This FileAccess allows us to read and write to files with permission to both read and write operations. |
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement