我正在开发一个使用SQLite的Windows Phone 8应用程序,并试图检查数据库是否存在,如果它不存在,它应该被创建。但我不断收到错误消息“System.windows.shapes.path不包含联合的定义”。还有其他方法可以做到吗或者我该如何改进?如何检查数据库是否存在于SQLite中?
public static string DB_PATH = Path.Combine(Path.Combine(ApplicationData.Current.LocalFolder.Path, "ContactsManager.sqlite"));//DataBase Name
public App()
{
if (!CheckFileExists("ContactsManager.sqlite").Result)
{
using (var db = new SQLiteConnection(DB_PATH))
{
db.CreateTable<Contacts>();
}
}
}
private async Task<bool> CheckFileExists(string fileName)
{
try
{
var store = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync(fileName);
return true;
}
catch
{
}
return false;
}
Path.Combine在System.IO.Path定义。 –