【发布时间】:2011-06-06 14:01:52
【问题描述】:
我从数据库中提取一个 BLOB 并存储在一个字节数组中。最初它被定义为与 DB 上的 BLOB 列相同的大小,这是相当大的。
int maxsize = 20971520;
int thisSize;
Byte[] picture = new Byte[maxsize];
所以我抓住了blob:
rdr.GetBytes(3, 0, picture, 0, maxsize);
然后将其写入磁盘:
FileStream fstream = new FileStream(ImageFullName,FileMode.OpenOrCreate,FileAccess.Write);
BinaryWriter bwriter = new BinaryWriter(fstream);
bwriter.Write(picture);
bwriter.Flush();
bwriter.Close();
fstream.Close();
问题是这些 blob 中的大多数都比 maxsize 小得多,那么如何将 Byte 数组的大小调整为 blob 列的实际大小?
【问题讨论】: