Connect to sqlite database on win IOT

寵の児 提交于 2019-12-13 03:56:05

问题


I'm getting error {SQLite.Net.SQLiteException: Could not open database file: C:\Data\Users\DefaultAccount\Documents\Storage.db (CannotOpen) when trying to connect to sqllite database on a raspberry pi 3, with WIN IOT is the OS. I'm using the SQLite.Net-PCL ver 3.1.1 implementation of SQLite.

var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);    var fileName2 = "Storage.db";
var path2 = Path.Combine(documentsPath, fileName2);     

try
        {
            using (var connection = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path2))
            {

            }
        }
        catch (Exception ex)
        {
            string m_er = ex.ToString();
        }
|improve this question

回答1:


I suppose you use UWP application. On Windows IoT Core you can use FolderPermissions tool to make this path "C:\Data\Users\DefaultAccount\Documents" accessible to a UWP app.

FolderPermissions C:\Data\Users\DefaultAccount\Documents -e

Since you don't receive "access denied" error so I suppose you have already added the following capability in the Package.appxmanifest.

<uap:Capability Name="documentsLibrary" />

Then your code will work. (I test on Raspberry Pi 3 with Windows IoT Core version 10.0.17763.107)



来源:https://stackoverflow.com/questions/54315079/connect-to-sqlite-database-on-win-iot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!