Initializes a new instance of the FileStream object for the specified file handle, with the specified read/write permission, FileStream instance ownership, and synchronous or asynchronous state.
[Visual Basic] Overloads Public Sub New( _ ByVal handle As Integer, _ ByVal access As FileAccess, _ ByVal ownsHandle As Boolean, _ ByVal isAsync As Boolean _ ) [C#] public FileStream( int handle, FileAccess access, bool ownsHandle, bool isAsync ); [C++] public: FileStream( int handle, FileAccess access, bool ownsHandle, bool isAsync ); [JScript] public function FileStream( handle : int, access : FileAccess, ownsHandle : Boolean, isAsync : Boolean );
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | access is not a field of FileAccess. |
ArgumentOutOfRangeException | bufferSize is not positive. |
IOException | An I/O error occurs. For example, if the access requested is not permitted by the operating system for the specified handle. Or, access is read/write and there is an attempt to open the existing file "c:\\Dir\\myfile.txt", but the file or directory is set for read-only access. |
SecurityException | The caller does not have the required FileIOPermission. |
The FileStream object is given the specified access to the file. The ownership of the handle will be as specified. If this process owns the handle, a call to the Close method will also close the handle. In particular, the file's handle count is decremented. The FileStream object is given the specified buffer size.
NGWS Runtime Security:
FileIOPermissionAccess | Read flag required by FileAccess.Read and FileAccess.ReadWrite. |
FileIOPermissionAccess | Write flag required by FileAccess.Write and FileAccess.ReadWrite. |
FileStream Class | FileStream Members | System.IO Namespace | FileStream Constructor Overload List