我有一個問題,當我想創建數據庫並指定它的名稱時,它是在指定的目錄和應用程序正在運行的目錄中創建的。爲什麼會發生?創建數據庫Sqlite c#創建2個相同的命名數據庫
代碼:
private static string AddDb(string dbName, string dbPassword)
{
try
{
string startupPath = Environment.CurrentDirectory;
string dataBasePath = startupPath + "\\DB\\" + dbName;
SQLiteConnection.CreateFile(dataBasePath);
SQLiteConnection dbConnString;
dbConnString = new SQLiteConnection("Data Source =" + dbName + ";Version=3;");
dbConnString.Open();
dbConnString.ChangePassword(dbPassword);
dbConnString.Close();
return dataBasePath;
}
catch
{
MessageBox.Show("Failed to create database", "DB Creator");
return "";
}
}
看來這個調用是在exe目錄下創建一個sqlite文件 dbConnString.Open(); – phoenix