问:我无法在Documents文件夹中打开sqlite数据库:
应用程序:通用Windows(10)平台
开发:C#,Visual Studio 2015
sqlite:使用sqlite.net
目标:Windows 10桌面和Windows 10手机
部署:从Visual Studio或Sideloaded(不需要存储部署)
using sqlite; using sqlite; using sqlite.Net; using sqlite.Net.Async; using sqlite.Net.Attributes
我可以:
using (sqlite.Net.sqliteConnection conn = new sqlite.Net.sqliteConnection (new sqlite.Net.Platform.WinRT.sqlitePlatformWinRT(),".\\mydb.db3")) { //Read queries }
打开/创建和读/写数据库到apps工作区:
string path = Path.Combine (Windows.Storage.ApplicationData.Current.LocalFolder.Path,"another.db3"); using (sqlite.Net.sqliteConnection conn = new sqlite.Net.sqliteConnection (new sqlite.Net.Platform.WinRT.sqlitePlatformWinRT(),path)) { //CRUD }
>将another.db3复制到Documents
>从那里复制到外部存储设备(SD卡)
我不能
>在Documents或SD中打开数据库
我使用FilePicker在Documents或SD中选择db
然后,在尝试打开数据库连接时,我使用File.Path属性
Windows.Storage.StorageFile File = await FilePicker.PickSingleFileAsync(); string path = File.Path;
我尝试打开该连接时收到以下错误消息:
Exception thrown: ‘sqlite.Net.sqliteException’ in sqlite.Net.dll
sqlite-GetAllVendors: Could not open database file: C:\Users\me\Documents\another.db3 (CannotOpen)
<Extensions> <uap:Extension Category="windows.fileTypeAssociation"> <uap:FileTypeAssociation Name=".db"> <uap:DisplayName>sqliteDB</uap:DisplayName> <uap:EditFlags OpenIsSafe="true" /> <uap:SupportedFileTypes> <uap:FileType>.db</uap:FileType> <uap:FileType>.db3</uap:FileType> </uap:SupportedFileTypes> </uap:FileTypeAssociation> </uap:Extension> </Extensions> </Application> </Applications>
<Capabilities> <Capability Name="internetClient" /> <uap:Capability Name="picturesLibrary" /> <uap:Capability Name="documentsLibrary" /> <uap:Capability Name="videosLibrary" /> <uap:Capability Name="userAccountInformation" /> <uap:Capability Name="removableStorage" /> <DeviceCapability Name="webcam" /> <DeviceCapability Name="location" /> </Capabilities>