我有一个用C#编写的Windows 10 UWP应用程序。我使用SQLite在本地存储我的数据。我遇到的问题是该文件从不保存和/或使用此代码检索。它应该可以工作,但是我找不到什么问题。SQLite不存储/检索数据库
dbExists总是评估为false,所以我在这里错过了什么?
private SQLiteConnection localConn;
private string dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "myDatabase.db");
public async void DBInit()
{
bool dbExists = false;
try
{
var store = await ApplicationData.Current.LocalFolder.GetFileAsync(dbPath);
dbExists = true;
}
catch { dbExists = false; }
if (!dbExists)
{
using (localConn = new SQLiteConnection(new SQLitePlatformWinRT(), dbPath))
{
// Create table
localConn.CreateTable<MyTable>();
}
}
else // CURRENTLY NOT FIRING!!
{}
}
为'dbExists'是'FALSE'此代码段中是唯一的出路,如果'GetFileAsync'引发异常。你捕捉(吞咽)的例外是什么? – IInspectable
你是如何在你的项目中包含你的'myDatabase.db'的?并在您的解决方案中的哪个项目? – Herdo