你可能会这样做。在 MSDN 上找到。可能它可以满足您的目的
// Reset the starting byte for the new BLOB.
startIndex = 0;
// Read the bytes into outbyte[] and retain the number of bytes returned.
retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize);
// Continue reading and writing while there are bytes beyond the size of the buffer.
while (retval == bufferSize)
{
bw.Write(outbyte);
bw.Flush();
// Reposition the start index to the end of the last buffer and fill the buffer.
startIndex += bufferSize;
retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize);
}
// Write the remaining buffer.
bw.Write(outbyte, 0, (int)retval - 1);
bw.Flush();
http://msdn.microsoft.com/en-us/library/87z0hy49%28v=vs.71%29.aspx#Y132
或者这个
int ndx = rdr.GetOrdinal("<ColumnName>");
if(!rdr.IsDBNull(ndx))
{
long size = rdr.GetBytes(ndx, 0, null, 0, 0); //get the length of data
byte[] values = new byte[size];
int bufferSize = 1024;
long bytesRead = 0;
int curPos = 0;
while (bytesRead < size)
{
bytesRead += rdr.GetBytes(ndx, curPos, values, curPos, bufferSize);
curPos += bufferSize;
}
}