1
我在VS17寫代碼和代碼使用存儲在xlsx
文件數據庫(到目前爲止,它被用來通過讀取文件的路徑和使用OLE.DB閱讀它):Embeding XLSX fileinto EXE C#
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]}
。
我怎樣才能使它成爲一個路徑或文件,我實際上可以使用它的單元格中的值作爲數據庫?
謝謝
保存它到一個臨時文件? –