FileStream Constructor (SafeFileHandle, FileAccess, Int32, Boolean)
Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission, buffer size, and synchronous or asynchronous state.
Assembly: mscorlib (in mscorlib.dll)
'Declaration Public Sub New ( _ handle As SafeFileHandle, _ access As FileAccess, _ bufferSize As Integer, _ isAsync As Boolean _ ) 'Usage Dim handle As SafeFileHandle Dim access As FileAccess Dim bufferSize As Integer Dim isAsync As Boolean Dim instance As New FileStream(handle, _ access, bufferSize, isAsync)
- Type: Microsoft.Win32.SafeHandles.SafeFileHandle
A file handle for the file that this FileStream object will encapsulate.
- Type: System.IO.FileAccess
- Type: System.Int32
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.
- Type: System.Boolean
true if the handle was opened asynchronously (that is, in overlapped I/O mode); otherwise, false.
The handle parameter is an invalid handle.
The handle parameter is a synchronous handle and it was used asynchronously.
The bufferSize parameter is negative.
An I/O error occurs, such as a disk error.
The stream has been closed.
The caller does not have the required permission.
The access requested is not permitted by the operating system for the specified file handle, such as when access is Write or ReadWrite and the file handle is set for read-only access.
FileStream assumes that it has exclusive control over the handle. Reading, writing, or seeking while a FileStream is also holding a handle could result in data corruption. For data safety, call Flush before using the handle, and avoid calling any methods other than Close after you are done using the handle. Alternately, read and write to the handle before calling this FileStream constructor.
FileShare.Read is the default for those FileStream constructors without a FileShare parameter.
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.
for permission to call unmanaged code. Associated enumerations: SecurityPermissionFlag.UnmanagedCode
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.