【发布时间】:2013-03-27 08:10:25
【问题描述】:
我一直在使用 XAML 和 C# 编写 Windows 8 应用商店应用程序,目标设备是 Windows Surface 平板电脑。
在我的应用程序中,我使用 SQLite 数据库。
要创建/加载数据库,我使用以下代码:
DBPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "MyDatabase.sqlite");
但是我想将数据库存储在 Documents 文件夹中,所以我尝试了以下代码行来替换我上面的行:
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 数据库保存到文档文件夹吗?
提前致谢。
【问题讨论】:
标签: c# sqlite windows-runtime windows-store-apps