NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

FileStream Constructor (Int32, FileAccess, Boolean, Boolean)

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
);

Parameters

handle
A file handle for the file that this FileStream object will encapsulate.
access
A FileAccess constant that determines how the file may be accessed by the FileStream object. This sets the CanRead and CanWrite properties of the FileStream object. CanSeek is set to true if path specifies a disk file.
ownsHandle
true if the file handle will be owned by this FileStream instance; otherwise, false.
isAsync
true if the handle was opened asynchronously (that is, in overlapped I/O mode); otherwise, false.

Exceptions

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.

Remarks

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.

Requirements

NGWS Runtime Security:

FileIOPermissionAccess Read flag required by FileAccess.Read and FileAccess.ReadWrite.
FileIOPermissionAccess Write flag required by FileAccess.Write and FileAccess.ReadWrite.

See Also

FileStream Class | FileStream Members | System.IO Namespace | FileStream Constructor Overload List