问题
i'm making 2 UWP apps, and i want to make them share 1 DB.
i'm using Microsoft.Data.SQLite
however, is there any way to share the same DB??
SqliteConnection db = new SqliteConnection("Filename=data.db"));
"Filename=data.db" path was c:\Users(user name)\AppData\Local\Packages(App ID)\LocalState\data.db
However, I know UWP app can only access that c:\Users\ (username)\AppData\Local\Packages(App ID)\LocalState\ folder except shared app data folders.
So, can you tell me how to direct the shared app data folder to Connection String?
回答1:
Are two ways to that:
1) Creates a button to call user action to select the common folder using a Picker to file or folder. Your application stores the access token returned by this explicit authorization and use that in future with no new user interaction.
2) Have a few ways to app get store authorization, but some that needs an enterprise Windows Store association (like Documents Library). I not sure, but for some locations, in the app validation you will be required to justify the needs before to publish your app.
More details in here: https://docs.microsoft.com/en-us/windows/uwp/files/file-access-permissions. See the title "Accessing additional locations".
来源:https://stackoverflow.com/questions/48457786/how-to-direct-shared-path-to-microsoft-data-sqlite-connection-string-uwp