FileStream.FileStream(SafeFileHandle, FileAccess, Int32) Constructor
Assembly: mscorlib (in mscorlib.dll)
public function FileStream ( handle : SafeFileHandle, access : FileAccess, bufferSize : int )
A file handle for the file that the current FileStream object will encapsulate.
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.
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.
- FileIOPermission for reading, writing, and appending to files. Associated enumerations: FileIOPermissionAccess.Read, FileIOPermissionAccess.Write, and FileIOPermissionAccess.Append.
- SecurityPermission for permission to call unmanaged code. Associated enumerations: SecurityPermissionFlag.UnmanagedCode
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.