Opens a System.IO.FileStream on the specified path with read/write access.
- mode
- A System.IO.FileMode value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.
- path
- The file to open.
- mode
- A System.IO.FileMode value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten.
A System.IO.FileStream opened in the specified mode and path, with read/write access and not shared.
Type Reason System.Security.SecurityException The caller does not have the required permission. ArgumentException path is a zero-length string, contains only white space, or contains one or more implementation-specific invalid characters. System.IO.FileNotFoundException path was not found. ArgumentNullException path is null. ArgumentOutOfRangeException mode specified an invalid value. System.IO.DirectoryNotFoundException The directory information specified in path was not found. System.IO.IOException An I/O error occurred while opening the file. UnauthorizedAccessException The caller does not have the required permission. System.IO.PathTooLongException The length of path or the absolute path information for path exceeds the system-defined maximum length.
The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see Directory.GetCurrentDirectory.
For a list of common I/O tasks, see Common I/O Tasks.
Type | Reason |
---|---|
System.Security.Permissions.FileIOPermission | Requires permission to read and write the file. See System.Security.Permissions.FileIOPermissionAccess.Read and System.Security.Permissions.FileIOPermissionAccess.Write. |