使用c#在winrt中使用SQLiteConnection的问题?

使用c#在winrt中使用SQLiteConnection的问题?,c#,sqlite,windows-runtime,C#,Sqlite,Windows Runtime,我是WinRT开发的新手。我尝试在c#中使用sqlite,但是当我尝试连接到本地数据库文件时,如下所示: string path = @"D:\product.s3db"; string constr = "Data Source=" + path + "; Version=3; PRAGMA temp_store_directory=" + Windows.Storage.ApplicationData.Current.TemporaryFolder.Path; SQLiteConnectio

我是WinRT开发的新手。我尝试在c#中使用sqlite,但是当我尝试连接到本地数据库文件时,如下所示:

string path = @"D:\product.s3db";
string constr = "Data Source=" + path + "; Version=3; PRAGMA temp_store_directory=" + Windows.Storage.ApplicationData.Current.TemporaryFolder.Path;
SQLiteConnection con = new SQLiteConnection(constr);

它返回一个异常“无法打开数据库文件”,那么这里出了什么问题?

我认为原因是WinRT应用程序是沙盒式的,对文件系统的访问有限。请尝试将数据库存储在应用程序可用的文件夹中

查看这篇文章,可能会有所帮助。

您可能错过了文件路径中的“:”符号。D:\数据。mdf@Oleg不,不是这样,而且我用它和我从win explorer复制粘贴的其他位置一起使用,但没有work@harryremon您确定D:\Data.mdf sqlite db吗?很抱歉,不是,但我尝试使用sqlite3数据库(product.s3db),它也失败了,但出现了相同的异常。这应该是您正在寻找的答案。下面是我今天运行的一些代码中的一个示例,它显示了dixeon的链接所指向的一个可能的存储位置:
string dbRootPath=Windows.storage.ApplicationData.Current.LocalFolder.Path;使用(SQLiteConnection db=newsqliteconnection(Path.Combine(dbRootPath,“dbname.sqlite”)))
非常感谢您,现在我要做的就是确保在部署时将db文件复制到本地文件夹。。。你知道怎么做吗?