我一直在使用XAML和C#编写Windows 8 Store应用程序,目标设备是Windows Surface平板电脑。将SQLite数据库保存到文档文件夹win Windows Store应用程序
在我的应用程序中,我使用了SQLite数据库。
要创建/加载我使用下面的代码数据库:
DBPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "MyDatabase.sqlite");
不过,我想存储在文档数据库文件夹,所以我尝试的代码的后续行取代我上面的一行:
DBPath = Path.Combine(Windows.Storage.KnownFolders.DocumentsLibrary.Path, "MyDatabase.sqlite");
当我尝试这一点,我得到以下错误:
WinRT information: Access to the specified location (DocumentsLibrary) requires a capability to be declared in the manifest.
所以我打开Package.appxmanifest并选择功能下的文档库,并在添加了文件类型关联的声明选项卡下。然后在属性下,我在名称框中输入了 sqlite,在文件类型框中输入了.sqlite。我在Package.appxmanifest屏幕上没有输入任何其他信息。
现在,当我运行应用程序,我收到以下错误:
Could not open database file: MyDatabase.sqlite (CannotOpen)
当我检查Windows.Storage.KnownFolders.DocumentsLibrary.Path它等于“”。我会期待这里的完整位置路径。
任何人都可以帮忙,并有任何人曾经将SQLite数据库保存到文档文件夹?
在此先感谢。