Export (0) Print
Expand All

SqlFileStream Class

Exposes SQL Server data that is stored with the FILESTREAM column attribute as a sequence of bytes.

System.Object
  System.MarshalByRefObject
    System.IO.Stream
      System.Data.SqlTypes.SqlFileStream

Namespace:  System.Data.SqlTypes
Assembly:  System.Data (in System.Data.dll)

'Declaration
Public NotInheritable Class SqlFileStream _
	Inherits Stream

The SqlFileStream type exposes the following members.

  NameDescription
Public methodSqlFileStream(String, Byte(), FileAccess)Initializes a new instance of the SqlFileStream class.
Public methodSqlFileStream(String, Byte(), FileAccess, FileOptions, Int64)Initializes a new instance of the SqlFileStream class.
Top

  NameDescription
Public propertyCanReadGets a value indicating whether the current stream supports reading. (Overrides Stream.CanRead.)
Public propertyCanSeekGets a value indicating whether the current stream supports seeking. (Overrides Stream.CanSeek.)
Public propertyCanTimeoutGets a value indicating whether the current stream can time out. (Overrides Stream.CanTimeout.)
Public propertyCanWriteGets a value indicating whether the current stream supports writing. (Overrides Stream.CanWrite.)
Public propertyLengthGets a value indicating the length of the current stream in bytes. (Overrides Stream.Length.)
Public propertyNameGets the logical path of the SqlFileStream passed to the constructor.
Public propertyPositionGets or sets the position within the current stream. (Overrides Stream.Position.)
Public propertyReadTimeoutGets or sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out. (Overrides Stream.ReadTimeout.)
Public propertyTransactionContextGets or sets the transaction context for this SqlFileStream object.
Public propertyWriteTimeoutGets or sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out. (Overrides Stream.WriteTimeout.)
Top

  NameDescription
Public methodBeginReadBegins an asynchronous read operation. (Overrides Stream.BeginRead(Byte(), Int32, Int32, AsyncCallback, Object).)
Public methodBeginWriteBegins an asynchronous write operation. (Overrides Stream.BeginWrite(Byte(), Int32, Int32, AsyncCallback, Object).)
Public methodCloseCloses the current stream and releases any resources (such as sockets and file handles) associated with the current stream. Instead of calling this method, ensure that the stream is properly disposed. (Inherited from Stream.)
Public methodCopyTo(Stream)Reads the bytes from the current stream and writes them to another stream. (Inherited from Stream.)
Public methodCopyTo(Stream, Int32)Reads the bytes from the current stream and writes them to another stream, using a specified buffer size. (Inherited from Stream.)
Public methodCopyToAsync(Stream)Asynchronously reads the bytes from the current stream and writes them to another stream. (Inherited from Stream.)
Public methodCopyToAsync(Stream, Int32)Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size. (Inherited from Stream.)
Public methodCopyToAsync(Stream, Int32, CancellationToken)Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token. (Inherited from Stream.)
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodDisposeReleases all resources used by the Stream. (Inherited from Stream.)
Public methodEndReadWaits for the pending asynchronous read to complete. (Overrides Stream.EndRead(IAsyncResult).)
Public methodEndWriteEnds an asynchronous write operation. (Overrides Stream.EndWrite(IAsyncResult).)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodFlushclears all buffers for this stream and causes any buffered data to be written to the underlying device. (Overrides Stream.Flush.)
Public methodFlushAsyncAsynchronously clears all buffers for this stream and causes any buffered data to be written to the underlying device. (Inherited from Stream.)
Public methodFlushAsync(CancellationToken)Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests. (Inherited from Stream.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodReadReads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Overrides Stream.Read(Byte(), Int32, Int32).)
Public methodReadAsync(Byte(), Int32, Int32)Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. (Inherited from Stream.)
Public methodReadAsync(Byte(), Int32, Int32, CancellationToken)Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests. (Inherited from Stream.)
Public methodReadByteReads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. (Overrides Stream.ReadByte.)
Public methodSeekSets the position within the current stream. (Overrides Stream.Seek(Int64, SeekOrigin).)
Public methodSetLengthSets the length of the current stream. (Overrides Stream.SetLength(Int64).)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodWriteWrites a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Overrides Stream.Write(Byte(), Int32, Int32).)
Public methodWriteAsync(Byte(), Int32, Int32)Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. (Inherited from Stream.)
Public methodWriteAsync(Byte(), Int32, Int32, CancellationToken)Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests. (Inherited from Stream.)
Public methodWriteByteWrites a byte to the current position in the stream and advances the position within the stream by one byte. (Overrides Stream.WriteByte(Byte).)
Top

  NameDescription
Public Extension MethodAsInputStreamConverts a managed stream in the .NET for Windows Store apps to an input stream in the Windows Runtime. (Defined by WindowsRuntimeStreamExtensions.)
Public Extension MethodAsOutputStreamConverts a managed stream in the .NET for Windows Store apps to an output stream in the Windows Runtime. (Defined by WindowsRuntimeStreamExtensions.)
Top

The SqlFileStream class is used to work with varbinary(max) data stored with the FILESTREAM attribute in a SQL Server 2008 database. You must install the .NET Framework 3.5 SP1 (or later) to use System.Data.SqlTypes.SqlFileStream to work with FILESTREAM data.

Specifying the FILESTREAM attribute on a varbinary(max) column causes SQL Server to store the data in the local NTFS file system instead of in the database file. Transact-SQL statements provide data manipulation capabilities within the server, and Win32 file system interfaces provide streaming access to the data.

NoteNote

Individual files stored in a FILESTREAM column cannot be opened directly from the NTFS file system. Streaming FILESTREAM data works only in the context of a SQL Server transaction.

The SqlFileStream class is derived from the Stream class, which represents an abstraction of a sequence of bytes from some arbitrary data source such as a file or a block of memory. You can read from a FILESTREAM by transferring data from a stream into a data structure such as an array of bytes. You can write to a FILESTREAM by transferring the data from a data structure into a stream. You can also seek within the stream, which allows you to query and modify data at the current position within the stream.

For conceptual documentation and code examples, see FILESTREAM Data.

For documentation about setting up and configuring FILESTREAM data on SQL Server, see Designing and Implementing FILESTREAM Storage in SQL Server 2008 Books Online.

.NET Framework

Supported in: 4.5, 4, 3.5 SP1, 3.0 SP2, 2.0 SP2

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft