Initializes a new instance of the FileStream object with the specified path and creation mode.
[Visual Basic] Overloads Public Sub New( _ ByVal path As String, _ ByVal mode As FileMode _ ) [C#] public FileStream( string path, FileMode mode ); [C++] public: FileStream( String* path, FileMode mode ); [JScript] public function FileStream( path : String, mode : FileMode );
Exception Type | Condition |
---|---|
ArgumentNullException | path is either null or an empty string. |
ArgumentException | mode is not a field of FileMode. |
SecurityException | The caller does not have the required FileIOPermission. |
FileNotFoundException | The file cannot be found. |
IOException | An I/O error occurs. |
This constructor calls FileStream(String path, FileMode mode, FileAccess access, FileShare share, int bufferSize). The constructor is given read/write access to the file, and it is opened without sharing (that is, requests to open the file by this or another process will fail until the FileStream object has been closed). The buffer size is set to 8192 bytes (8 KB).
NGWS Runtime Security:
FileIOPermissionAccess | Append flag required by FileMode.Create or FileMode.CreateNew and by FileMode.OpenOrCreate if the file does not yet exist. |
FileIOPermissionAccess | Write flag required by FileMode.Create or FileMode.CreateNew, by FileMode.OpenOrCreate if the file already exists or does not exist, and by FileMode.Truncate. |
FileIOPermissionAccess | Read flag required by FileMode.Open. |
FileStream Class | FileStream Members | System.IO Namespace | FileStream Constructor Overload List