-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save SQLite file to MyDocuments #27580
Comments
What error? |
Well the error in my app was "Access denied" but this seems to have been due to a problem in my code.
|
A related question. If I use FileSavePicker.PickSaveFileAsync to let the user pick the file location, then it returns a StorageFile. Will SQLite be able to create the database using the path and filename from that StorageFile? I am not very clear on the exact status of the file indicated by the StorageFile returned from the picker and how that will interact with SQLite. |
When I moved the simplified BloggingContext to my app and tried the same MyButton_Click as above, it gave SQLite error 14, could not open file. So maybe something is off with my installation or my package. |
@sjb-sjb trying to read the above, there's a lot going on and it's not clear exactly what problem you have (or whether it's related to EF Core). Please try to submit a simple, runnable console program - without any code that is isn't needed, or Winforms, or anything - and post the full exception and stack trace you are seeing. |
OK. Did some experimenting early this morning. Using VS 2022 Community Edition, WindowsAppSDK installed, workloads for .NET desktop development and UWP development. Details per item 5 in the above posting. I am executing as a normal user, not as an Administrator. Steps to reproduce:
Stack trace for Sqlite error 14
Stack trace for ending exception
|
I have opened an issue 6817 in microsoft-ui-xaml in respect of the exceptions that happen when you exit the program. These do not seem to be related to EF Core given that they occur even if EF Core is not referenced. The issue in this posting (#27580) is the SQLite error 14 and the fact that three files instead of 1 are left over after exiting. I suppose that the three exceptions reporting in 6817 could be an indirect cause of having 3 files left over, if they prevent SQLite from cleaning up. |
This was fixed in 6.0.1--see #26422. Please make sure to always use the latest patch version of a release. |
OK !! Thanks for the tip. |
Catching up with the fact that this was discussed in microsoft/WindowsAppSDK#8 |
Note from triage: issues with StorageFile are well-known. We don't intend to make any changes in EF for this. |
See #30642 |
With the resolution of #24213, when building a packaged app with WindowsAppSDK we can now save SQLite databases into the AppDir:
However, if we substitute SpecialFolder.MyDocuments, an error occurs. To my (limited) knowledge there is not a hard reason for this because the file redirection model would seem to say that outside of the AppDir, as long as the user has permissions on the directory they can access files there.
There would be many advantages to being able to save an SQLite database to My Documents. One key reason to do so is so that SQLite can then be used as a document format, with the documents remaining in place in MyDocuments if the app is removed. I believe there is even a MS guideline somewhere saying roughly that AppDir should only be used for non-critical data that can be deleted without significant repercussions. In addition, MyDocuments is backed up to cloud storage by OneDrive sync, providing a high level of security and retention of the data.
If app developers cannot save SQLite databases to MyDocuments but need to keep non-transient data in SQLite, then they are forced to write their own code to copy the SQLite file over to MyDocuments. That is not very easy to do well, and is essentially duplicating existing Windows sync features that apply to non-AppDir directories.
Would welcome this feature and/or any suggestions on workarounds.
The text was updated successfully, but these errors were encountered: