SqlFileStream Constructor (String, Byte, FileAccess, FileOptions, Int64)
Initializes a new instance of the SqlFileStream class.
Assembly: System.Data (in System.Data.dll)
public SqlFileStream( string path, byte transactionContext, FileAccess access, FileOptions options, long allocationSize )
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.
The transaction context for the SqlFileStream object. When set to null, an implicit transaction will be used for the SqlFileStream object. Applications should return the byte array returned by calling the GET_FILESTREAM_TRANSACTION_CONTEXT method.
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.IOSeek methods to move the handle position within the file to write or append new data.
- Type: System.IO.FileOptions
The allocation size to use while creating a file. If set to 0, the default value is used.
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 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.
If an exception is thrown, any open transactions should be rolled back. Otherwise, data loss can occur.
Available since 2.0