【发布时间】:2017-09-04 05:43:32
【问题描述】:
我在 VS17 中编写了代码,该代码使用了存储在 xlsx 文件中的数据库(到目前为止,它是通过读取文件的路径并使用 OLE.DB 读取它来使用的):
string DataBase_File = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory.ToString(), String.Format("{0}", db_name));
string constr = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0 Xml;HDR=NO""", DataBase_File);
using (OleDbConnection conn = new OleDbConnection(constr))
{
conn.Open();
OleDbCommand command = new OleDbCommand(string.Format("Select * from [{0}]", SheetName), conn);
OleDbDataReader reader = command.ExecuteReader();
当我想将它编译成.exe 文件时,我通过以下方式将该文件添加到资源中:
var fileString = namespace.Properties.Resources.DataBase;
但是,我得到的结果是 fileString 是 {bytes[28432]}。
我怎样才能使它成为一个路径或文件,我可以实际使用它单元格中的值作为数据库?
谢谢
【问题讨论】:
-
保存到临时文件?