BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 System.Enum System.Runtime.InteropServices.ComVisible(true)

For an example of creating a file and writing text to a file, see [<topic://cpconwritingtexttofile>]. For an example of reading text from a file, see [<topic://cpconreadingtextfromfile>]. For an example of reading from and writing to a binary file, see [<topic://cpconReadingWritingToNewlyCreatedDataFile>].

A FileMode parameter is specified in many of the constructors for , , and in the Open methods of and to control how a file is opened.

FileMode parameters control whether a file is overwritten, created, opened, or some combination thereof. Use Open to open an existing file. To append to a file, use Append. To truncate a file or create a file if it doesn't exist, use Create.

Specifies how the operating system should open a file.

- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.FileMode Append To be added.

  Opens the file if it exists and seeks to the end of the file, or creates a new file. This requires permission. FileMode.Append can be used only in conjunction with FileAccess.Write. Trying to seek to a position before the end of the file throws an exception, and any attempt to read fails and throws a exception.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.FileMode Create To be added.

  Specifies that the operating system should create a new file. If the file already exists, it will be overwritten. This requires permission. FileMode.Create is equivalent to requesting that if the file does not exist, use ; otherwise, use . If the file already exists but is a hidden file, an exception is thrown.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.FileMode CreateNew To be added.

  Specifies that the operating system should create a new file. This requires permission. If the file already exists, an exception is thrown.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.FileMode Open To be added.

  Specifies that the operating system should open an existing file. The ability to open the file is dependent on the value specified by the enumeration. A exception is thrown if the file does not exist.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.FileMode OpenOrCreate To be added.

  Specifies that the operating system should open a file if it exists; otherwise, a new file should be created. If the file is opened with FileAccess.Read, permission is required. If the file access is FileAccess.Write, permission is required. If the file is opened with FileAccess.ReadWrite, both and permissions are required.

  0
- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.FileMode Truncate To be added.

  Specifies that the operating system should open an existing file. When the file is opened, it should be truncated so that its size is zero bytes. This requires permission. Attempts to read from a file opened with FileMode.Truncate cause an exception.

  0
0