简体   繁体   English

对位于AppData文件夹中的文件使用SQLConnection

[英]Using SQLConnection with files located in AppData folder

I downloaded a NuGet Package that uses sqlite-net-pcl and a few other libraries. 我下载了使用sqlite-net-pcl和其他一些库的NuGet软件包。 It seems like all of them support UWP , because the Package Manager didn't throw an exception. 似乎它们所有人都支持UWP ,因为软件包管理器没有引发异常。

The problem I'm facing right now is the fact that my database file is in the ApplicationData.Current.LocalFolder directory, and it doesn't seem like SQLite.SqlConnection can access it via path that way: 我现在面临的问题是我的数据库文件位于ApplicationData.Current.LocalFolder目录中,而SQLite.SqlConnection似乎无法通过这种方式访问​​它:

Could not open database file: ms-appdata:///local/scrobbleCache.db (CannotOpen)

Is there any other way I can do this? 我还有其他方法可以做到吗?

Thank you! 谢谢!

Here is how you want to access SQLite DB. 这是您要访问SQLite DB的方式。

var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "scrobbleCache.db");  
using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))  
{  
    .....Do your Activity  
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM