将二进制内容存储到sqlite db中

时间:2014-03-07 19:20:23

标签: c# binary

我将图像存储到sqlite数据库中。指定的类型是BLOB fir图像字段。下面是存储它的代码,

FileInfo uploadedFileInfo = new FileInfo(Filename);
FileStream fs = fileInfo.OpenRead();
byte[] content = new byte[fs.Length];
fs.Read(content, 0, content.Length);
fs.Close();

并将此内容存储到db中。有时会报告; oad失败。 这个c#代码在64位机器上作为Windows服务运行。目标是AnyCPU。 代码中有什么问题吗?或者我需要将目标设置为x86。欢迎蚂蚁反馈! 此致

1 个答案:

答案 0 :(得分:0)

SQLite是一个本机组件,因此您需要将interop.dlls放入单独的文件夹中(在System.Data.SQLite.dll下面)

/System.Data.SQLite.dll (core assembly)
/x86/SQLite.Interop.dll (x86 native interop assembly)
/x64/SQLite.Interop.dll (x64 native interop assembly)