从sql数据库中将图片导出并重命名
while (dataReader1.Read())
{
//判断照片是否为空,不为空
if (dataReader1.GetValue(1) != DBNull.Value)
{
//数据库中获取到字节
fileData = (byte[])dataReader1.GetValue(1);
//照片路径
path = imageFolder + "\\" + sfzhm + "_" + xm + ".jpg";
MemoryStream ms = new MemoryStream(fileData);
Bitmap bmpt = new Bitmap(ms);
bmpt.Save(path);
if (bmpt != null)
{
//记得要释放,数据多的话
bmpt.Dispose();
}
}
else
{
//为空
path = imageFolder + "\\" + sfzhm + "_" + xm + ".jpg";
Bitmap bmpt = new Bitmap(100, 100);
bmpt.Save(path, ImageFormat.Jpeg);
if (bmpt != null)
{
bmpt.Dispose();
}
}
}