把数据库Image,Text类型存储成文件
来源:互联网 发布:朱元璋注老子知乎 编辑:程序博客网 时间:2024/04/29 10:42
//select pid,image from a
FileStream fs; // Writes the BLOB to a file (*.bmp).
BinaryWriter bw; // Streams the BLOB to the FileStream object.
int bufferSize = 100; // Size of the BLOB buffer.
byte[] outbyte = new byte[bufferSize]; // The BLOB byte[] buffer to be filled by GetBytes.
long retval; // The bytes returned from GetBytes.
long startIndex = 0; // The starting position in the BLOB output.
string pub_id = ""; // The publisher id to use in the file name.
while (myReader.Read())
{
// Get the publisher id, which must occur before getting the logo.
pub_id = myReader.GetString(1);
// Create a file to hold the output.
fs = new FileStream(Server.MapPath("logo" + pub_id + ".txt"), FileMode.OpenOrCreate, FileAccess.Write);
bw = new BinaryWriter(fs);
// 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(0, 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);
bw.Flush();
// Close the output file.
bw.Close();
fs.Close();
}
// Close the reader and the connection.
myReader.Close();
- 把数据库Image,Text类型存储成文件
- android将字串转换成文件存储
- Oracle数据库导出成文本文件
- 数据库读取二进制流还原成文件
- ArcGIS Text数据库内部存储类型
- oracle之把表文件导出成文本文件
- mountvol 命令,把磁盘映射成文件夹
- 关于Matlab中把figure保存成文件
- 怎样把文件夹中文件名保存成文件?
- gnuradio中把file_sink的二进制文件转换成文本文件
- 如何把mysql数据导出成文本文件
- 【Unity】把字符串保存成文件的2种方式
- Hibernate 读取TEXT IMAGE类型
- text/* image/* application/* 类型理解
- sql server数据库存储image类型的一种方法
- text 类型和image 类型的转换
- 如何将图片以Image类型存储到数据库 如何从数据库中读取Image类型的字段
- 在数据库中处理image字段【把图片存储到数据库并显示出来】
- Java创建TXT文件并进行读、写、修改操作
- flash socket
- 关于接口开发的一点心得
- zz : 基于80x86的Linux分段机制
- Truncate 和 Delete 的区别
- 把数据库Image,Text类型存储成文件
- 获取GPS 两点间的直线距离
- Server.MapPath()
- AD开发中OU组织机构的属性、 Group的属性
- 数据库中大字段类型处理
- Ubuntu/Linux入门介绍-VIM简介
- HDU2855 Fibonacci Check-up 矩阵的应用
- 列出一个数组里面的重复数字
- 敏捷开发,持续集成 CruiseControl.NET 自动发布 我的一点小实践 其中配置文件替换部分挺重要