简体   繁体   English

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

[英]proplem using SQLiteConnection in winrt using c#?

I'm new to WinRT development. 我是WinRT开发的新手。 I'm trying to use sqlite in c#, however when I try to connect to a local database file like this: 我正在尝试在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);

it returns an exception "Could not open database file", so what is wrong here? 它返回一个异常“无法打开数据库文件”,所以这里有什么问题?

I think reason is that WinRT applications are sand-boxed and have limited access to the file system. 我认为原因是WinRT应用程序是沙盒并且对文件系统的访问权限有限。 Please try to store database in folder that is available for your application. 请尝试将数据库存储在可用于您的应用程序的文件夹中。
Check the Windows 8: The Right Way to Read & Write Files in WinRT article, it may help. 检查Windows 8:WinRT文章中读写文件的正确方法 ,它可能有所帮助。

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

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