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

时间:2012-11-20 14:41:23

标签: 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;
SQLiteConnection con = new SQLiteConnection(constr);

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

1 个答案:

答案 0 :(得分:3)

我认为原因是WinRT应用程序是沙盒并且对文件系统的访问权限有限。请尝试将数据库存储在可用于您的应用程序的文件夹中。
查看Windows 8: The Right Way to Read & Write Files in WinRT文章,它可能会有帮助。