SqlFileStream Constructor (String, Byte, FileAccess)
Initializes a new instance of the SqlFileStream class.
Assembly: System.Data (in System.Data.dll)
public SqlFileStream( string path, byte transactionContext, FileAccess access )
- Type: System.String
The logical path to the file. The path can be retrieved by using the Transact-SQL Pathname function on the underlying FILESTREAM column in the table.
- Type: System.Byte
The transaction context for the SqlFileStream object. Applications should return the byte array returned by calling the GET_FILESTREAM_TRANSACTION_CONTEXT method.
- Type: System.IO.FileAccess
When using FileAccess.Read, the SqlFileStream object can be used to read all of the existing data.
When using FileAccess.Write, SqlFileStream points to a zero byte file. Existing data will be overwritten when the object is closed and the transaction is committed.
When using FileAccess.ReadWrite, the SqlFileStream points to a file which has all the existing data in it. The handle is positioned at the beginning of the file. You can use one of the System.IO Seek methods to move the handle position within the file to write or append new data.
path is a null reference, or transactionContext is null.
path is an empty string (""), contains only white space, or contains one or more invalid characters.
path begins with "\\.\", for example "\\.\PHYSICALDRIVE0 ".
The handle returned by the call to NTCreateFile is not of type FILE_TYPE_DISK.
options contains an unsupported value.
The file cannot be found.
An I/O error occurred.
The caller does not have the required permission.
The specified path is invalid, such as being on an unmapped drive.
The access requested is not permitted by the operating system for the specified path. This occurs when Write or ReadWrite access is specified, and the file or directory is set for read-only access.
NtCreateFile fails with error code set to ERROR_SHARING_VIOLATION.