FileStream Constructor (IntPtr, FileAccess)
NOTE: This constructor is now obsolete.
Initializes a new instance of the FileStream class for the specified file handle, with the specified read/write permission. Namespace: System.IOAssembly: mscorlib (in mscorlib.dll)
[ObsoleteAttribute("This constructor has been deprecated. Please use new FileStream(SafeFileHandle handle, FileAccess access) instead. http://go.microsoft.com/fwlink/?linkid=14202")] public FileStream ( IntPtr handle, FileAccess access )
/** @attribute ObsoleteAttribute("This constructor has been deprecated. Please use new FileStream(SafeFileHandle handle, FileAccess access) instead. http://go.microsoft.com/fwlink/?linkid=14202") */ public FileStream ( IntPtr handle, FileAccess access )
ObsoleteAttribute("This constructor has been deprecated. Please use new FileStream(SafeFileHandle handle, FileAccess access) instead. http://go.microsoft.com/fwlink/?linkid=14202") public function FileStream ( handle : IntPtr, access : FileAccess )
Parameters
- handle
- access
Exception type | Condition |
---|---|
access is not a field of FileAccess. | |
The caller does not have the required permission. | |
An I/O error occurs, such as a disk error. -or- The stream has been closed. | |
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. |
When Close is called, the handle is also closed and the file's handle count is decremented.
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.
![]() |
---|
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. |
FileShare.Read is the default for those FileStream constructors without a FileShare parameter.
The following table lists examples of other typical or related I/O tasks.
To do this... | See the example in this topic... |
---|---|
Create a text file. | |
Write to a text file. | |
Read from a text file. | |
Append text to a file. | |
Rename or move a file. | |
Delete a file. | |
Copy a file. | |
Get the size of a file. | |
Get the attributes of a file. | |
Set the attributes of a file. | |
Determine if a file exists. | |
Read from a binary file. | |
Write to a binary file. | |
Retrieve a file extension. | |
Retrieve the fully qualified path of a file. | |
Retrieve the file name and extension from a path. | |
Change the extension of a file. |
- FileIOPermission for reading, writing, and appending to files. Associated enumerations: FileIOPermissionAccess.Read, FileIOPermissionAccess.Write, and FileIOPermissionAccess.Append.
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.