A System.IO.FileStream that provides read/write access to the file specified in path.
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. ArgumentNullException path is null. System.IO.DirectoryNotFoundException The directory information specified in path was not found. System.IO.IOException An I/O error occurred while creating 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 System.IO.FileStream object created by this method has a default System.IO.FileShare value of FileShare.None; no other process or code can access the created file until the original file handle is closed.
This method is equivalent to the File.Create(string, int) method overload using the default buffer size.
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.
If the specified file does not exist, it is created; if it does exist and it is not read-only, the contents are overwritten.
By default, full read/write access to new files is granted to all users. The file is opened with read/write access and must be closed before it can be opened by another application.
For a list of common I/O tasks, see Common I/O Tasks.
Type | Reason |
---|---|
System.Security.Permissions.FileIOPermission | Requires permission to write the specified file. See System.Security.Permissions.FileIOPermissionAccess.Write. |