Assembly: Mediachase.FileUploader (in Mediachase.FileUploader.dll)
Syntax
Remarks
A common practice to reduce the amount of memory used when writing a BLOB value is to write the BLOB to the database in "chunks". The process of writing a BLOB to a database in this way depends on the capabilities of your database.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Use the SqlBlobStream class to read, write, create or close text, ntext, or image values from a text, ntext, or image column, as well as to manipulate other file-related operating system handles such as file.
SqlBlobStream objects support random access to files using the Seek method. Seek allows the read/write position to be moved to any position within the file. This is done with byte offset reference point parameters. The byte offset is relative to the seek reference point, which can be the beginning, the current position, or the end of the underlying file, as represented by the three properties of the SeekOrigin class.
For an example of using this class, see the Example section below.
Examples
Copy Code | |
|---|---|
|
string strConnectionString = "Data source=(local);Initial catalog=TestDB;User Id=sa;Password="; string strSqlTable = "Files"; string strBLOBColumn = "Data"; try { using(SqlBlobStream stream = new SqlBlobStream(strConnectionString, strSqlTable, strBLOBColumn, SqlBlobAccess.Read,new SqlParameter("@FileId",12345))) { byte[] tmpBuffer = new byte[1024]; int Length = 0; while((Length=stream.Read(buffer,0,1024))==1024) { //TODO: Save tmpBuffer } } } catch(Exception ex) { System.Diagnostics.Trace.WriteLine(ex); throw; } | |
Inheritance Hierarchy
System..::MarshalByRefObject
System.IO..::Stream
Mediachase.FileUploader..::SqlBlobStream








