FileStream.FileStream(String, FileMode, FileSystemRights, FileShare, Int32, FileOptions) Constructor
Assembly: mscorlib (in mscorlib.dll)
public FileStream ( string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, FileOptions options )
public FileStream ( String path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, FileOptions options )
public function FileStream ( path : String, mode : FileMode, rights : FileSystemRights, share : FileShare, bufferSize : int, options : FileOptions )
A relative or absolute path for the file that the current FileStream object will encapsulate.
A FileMode constant that determines how to open or create the file.
A FileSystemRights constant that determines the access rights to use when creating access and audit rules for the file.
A FileShare constant that determines how the file will be shared by processes.
A positive Int32 value greater than 0 indicating the buffer size. For bufferSize values between one and eight, the actual buffer size is set to eight bytes.
A FileOptions constant that specifies additional file options.
path is a null reference (Nothing in Visual Basic).
path is an empty string (""), contains only white space, or contains one or more invalid characters.
path refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in an NTFS environment.
path refers to a non-file device, such as "con:", "com1:", "lpt1:", etc. in a non-NTFS environment.
bufferSize is negative or zero.
mode, access, or share contain an invalid value.
The file cannot be found, such as when mode is FileMode.Truncate or FileMode.Open, and the file specified by path does not exist. The file must already exist in these modes.
The current operating system is not Windows NT or later.
An I/O error occurs, such as specifying FileMode.CreateNew and the file specified by path already exists.
The stream has been closed.
The caller does not have the required permission.
The specified path is invalid, such as being on an unmapped drive.
The access requested is not permitted by the operating system for the specified path, such as when access is Write or ReadWrite and the file or directory is set for read-only access.
Encrypted is specified for options, but file encryption is not supported on the current platform.
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The .NET Framework does not support direct access to physical disks through paths that are device names, such as "\\.\PHYSICALDRIVE0 ".
Use this FileStream constructor to apply access rights at the point of creation of a file. To access or modify rights on an existing file, consider using the GetAccessControl and SetAccessControl methods.
The fileOptions parameter is used to provide access to more advanced operations that can be leveraged when creating a FileStream object.
The path parameter can be a file name, including a file on a Universal Naming Convention (UNC) share.
path is not required to be a file stored on disk; it can be any part of a system that supports access through streams. For example, depending on the system, this class can access a physical device.
CanSeek is true for all FileStream objects that encapsulate files. If path indicates a device that does not support seeking, the CanSeek property on the resulting FileStream is false. For additional information, see CanSeek.
When you compile a set of characters with a particular cultural setting and retrieve those same characters with a different cultural setting, the characters might not be interpretable, and could cause an exception to be thrown.
For a list of common I/O tasks, see Common I/O Tasks.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter EditionThe Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.