我正在关注本教程使用 SQLite 数据库创建应用程序。
当我执行它时,我得到System.IO.FileNotFoundException指向文件SQLite.cs,错误所在的行显示在下面的屏幕截图中(在 SQLite.cs 文件中)
下面是创建数据库的代码片段
string dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
if (!FileExists(dbPath).Result)
{
using (var db = new SQLiteConnection(dbPath))
{
db.CreateTable<Person>();
}
}
和方法 FileExists
private async Task<bool> FileExists(string fileName)
{
var result = false;
try
{
var store = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync(fileName);
result =true;
}
catch
{
}
return result;
}
我想知道出了什么问题。有什么帮助吗?