我一直在使用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數據庫保存到文檔文件夾?
在此先感謝。