System.IO.FileAccess Enumeration

Defines constants for read, write, or read/write access to a file.

Syntax

[System.Flags]
[System.Runtime.InteropServices.ComVisible(true)]
public enum FileAccess

Remarks

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 FileAccess parameter is specified in many of the constructors for System.IO.File, System.IO.FileInfo, System.IO.FileStream, and other constructors where it is important to control the kind of access users have to a file.

Members

Member NameDescription
Read

Read access to the file. Data can be read from the file. Combine with Write for read/write access.

ReadWrite

Read and write access to the file. Data can be written to and read from the file.

Write

Write access to the file. Data can be written to the file. Combine with Read for read/write access.

Requirements

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0