-
大小: 41KB文件类型: .rar金币: 2下载: 1 次发布日期: 2021-06-12
- 语言: C#
- 标签: access2007 ole对象 图片 c#
资源简介
手工添加的access ole对象批量导出问题
困扰了我很久
现在已经解决了 希望能够帮助到大家!
附有用链接
http://dotnet.aspx.cc/file/Removing-OLE-Header-from-images-stored-in-MS-Access-DB-as-OLE-Object.aspx
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender EventArgs e)
{
}
//以下是从手工添加了ole对象的access2007数据库中导出二进制图片到本地的方法 具体使用情况请根据实际进行修改
//注意 手工添加ole对象与程序写入ole对象相比 会多出来一个文件头 所以在从数据库取出二进制图片后 需要进行去
//文件头的步骤
//该问题困扰了我很久 故上传 希望能帮助到大家
//如果你有足够的能耐 请联系mail@misxiu.com 新创业公司 期待您的加盟!一起书写商业传奇!
//2011年7月10日凌晨于杭州
private void button1_Click(object sender EventArgs e)
{
string conStr = “Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\\123.accdb“;
string accessAtr = “Select 编号回单扫描图片 From 调度单 where 回单扫描图片 is not null “;
OleDbConnection oleDbCon = new OleDbConnection(conStr);
oleDbCon.Open();
OleDbCommand oleDbCom = oleDbCon.CreateCommand();
//oleDbCom.CommandType = CommandType.Text;
oleDbCom.CommandText = accessAtr;
OleDbDataReader oleDbDR = oleDbCom.ExecuteReader();
try
{
while (oleDbDR.Read())
{
byte[] bfile = (byte[]) oleDbDR.GetValue(1);
bfile = GetImageBytesFromOLEField(bfile);//如果是手工添加的ole对象 必须执行此步骤
using (MemoryStream ms = new MemoryStream(bfile))
{
try
{
using (Image bigPhoto = Image.FromStream(ms))
{
bigPhoto.Save(“E://photo/“ + oleDbDR.GetValue(0) + “.jpg“);
}
}
catch
{
}
}
}
}
finally
{
oleDbDR.Close();
oleDbCon.Close();
}
}
//手工添加ole对象 去文件头方法
private byte[] GetImageBytesFromOLEField(byte[] oleFieldBytes)
{
const string BITMAP_ID_BLOCK = “BM“;
const string JPG_ID_BLOCK = “\u00FF\u00D8\u00FF“;
const string PNG_ID_BLOCK = “\u0089PNG\r\n\u001a\n“;
const string GIF_ID_BLOCK = “GIF8“;
const string TIFF_ID_BLOCK = “II*\u0000“;
byte[] imageBytes;
// Get a UTF7 Encoded string version
Encoding u8 = Encoding.UTF7;
string strTemp = u8.GetString(oleFieldBytes);
// Get the first 300 characters from the string
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 10240 2011-07-09 23:55 WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
文件 22016 2011-07-09 23:55 WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
文件 11600 2011-07-09 23:46 WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe
文件 4782 2011-07-10 04:06 WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs
文件 2037 2011-07-09 19:50 WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs
文件 5817 2011-07-09 19:50 WindowsFormsApplication1\WindowsFormsApplication1\Form1.resx
文件 4440 2011-07-09 23:45 WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6256 2011-07-09 23:55 WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 296 2011-07-09 23:55 WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\GenerateResource.read.1.tlog
文件 758 2011-07-09 23:55 WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\GenerateResource.write.1.tlog
文件 907 2011-07-09 23:55 WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt
文件 10240 2011-07-09 23:55 WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.exe
文件 180 2011-07-09 23:55 WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Form1.resources
文件 22016 2011-07-09 23:55 WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.pdb
文件 180 2011-07-09 23:55 WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Properties.Resources.resources
文件 505 2011-07-09 19:50 WindowsFormsApplication1\WindowsFormsApplication1\Program.cs
文件 1380 2011-07-09 19:50 WindowsFormsApplication1\WindowsFormsApplication1\Properties\AssemblyInfo.cs
文件 2896 2011-07-09 19:50 WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.Designer.cs
文件 5612 2011-07-09 19:50 WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.resx
文件 1107 2011-07-09 19:50 WindowsFormsApplication1\WindowsFormsApplication1\Properties\Settings.Designer.cs
文件 249 2011-07-09 19:50 WindowsFormsApplication1\WindowsFormsApplication1\Properties\Settings.settings
文件 3707 2011-07-09 19:52 WindowsFormsApplication1\WindowsFormsApplication1\WindowsFormsApplication1.csproj
文件 914 2011-07-09 19:50 WindowsFormsApplication1\WindowsFormsApplication1.sln
..A..H. 18432 2011-07-09 23:55 WindowsFormsApplication1\WindowsFormsApplication1.suo
目录 0 2011-07-09 19:50 WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\TempPE
目录 0 2011-07-09 23:55 WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug
目录 0 2011-07-09 23:55 WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug
目录 0 2011-07-09 19:50 WindowsFormsApplication1\WindowsFormsApplication1\obj\x86
目录 0 2011-07-09 19:50 WindowsFormsApplication1\WindowsFormsApplication1\bin
目录 0 2011-07-09 19:50 WindowsFormsApplication1\WindowsFormsApplication1\obj
............此处省略6个文件信息
- 上一篇:C#做注册界面 验证
- 下一篇:IEEE754浮点数转换器C#实现
相关资源
- c#车牌识别系统附30张测试图片
- 安卓和asp.net通过webservice上传图片到服
- C#绘图和图片放大缩小等功能代码
- winform图片标尺,画矩形
- C# PDF转图片
- C#做的一个图片浏览器源码
- 大图找小图 C#图片对比高速找图源码
- c# 图像旋转 winform 窗体 图片转动
- SQLserver+C#实现的KTV点歌系统 有数据库
- C#在图片中写入文字
- 用c#将pdf文件转换成图片文件
- C#源码:批量自动去除图片白边
- WinForm 实现图片滚动
- C# 图片管家
- WPF 3D图片触摸屏滑动效果(苹果浏览
- C#生成PDF 读取PDF文本内容 获取PDF内图
- 超漂亮带音乐的C#俄罗斯方块源代码能
- ZPL 打印条码、二维码及小票中文/汉字
- C# post模拟提交接收图片存到服务器上
- C# Winform画图板
- c# winform twain文件扫描并保存成图片
- u5-TW-C#打印操作--使用GDI绘图打印学生
- z1_C#打印操作--使用GDI绘图打印学生信
- C#打印操作--使用GDI绘图打印学生信息
- WPF加载和分页显示的图片列表,可多
- wpf 图片翻转特效
- C#生成PDF 读取PDF文本内容 获取PDF内图
- c# 操作word 插入 文字 表格 图片 转为
- C#图片对比高速找图源码20131021
- C#实现的全景图拼接两张图片合并成一
评论
共有 条评论