FileInfo.Open Method (FileMode)

May 11, 2014

Opens a file in the specified mode.

Namespace:  System.IO
Assembly:  mscorlib (in mscorlib.dll)

public FileStream Open(
	FileMode mode
)

Parameters

mode
Type: System.IO.FileMode
A FileMode constant specifying the mode (for example, Open or Append) in which to open the file.

Return Value

Type: System.IO.FileStream
A file opened in the specified mode, with read/write access and unshared.

ExceptionCondition
FileNotFoundException

The file is not found.

UnauthorizedAccessException

The file is read-only or is a directory.

DirectoryNotFoundException

The specified path is invalid, such as being on an unmapped drive.

IOException

The file is already open.

Version Notes

Windows Phone

 This member has a SecurityCriticalAttribute attribute. This attribute restricts this member to internal use. Application code that uses this member throws a MethodAccessException.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft