c# UWP store-app how to save file that will not be deleted after app uninstall

I noticed that file saved into ApplicationData.Current.LocalFolder.CreateFileAsync folder is removed after application uninstall.

Is that possible to save file that will remain in user profiler after application uninstall , so when user re-install application I can read settings from file for this user ?

Upvotes: 0

Views: 926

Answers (3)

Martin Zikmund
Martin Zikmund

Reputation: 39072

If your file is a small one, you can store it in ApplicationData.Current.RoamingFolder, which gets roamed across the user's devices. Disadvantages of this approach are that the file can get overwritten quite easily because of late sync from one of the devices and the fact that the file stays on cloud only for a limited time after the user uninstalls the app from all his devices. See more details about roaming here in Docs.

Apart from this, your only solution would be to either store the file on the users drive with his consent (using FileSavePicker or FolderPicker) or on his OneDrive, which is quite common as a backup option (here you need to integrate the OneDrive SDK and get user's consent).

Upvotes: 1

walterlv
walterlv

Reputation: 2376

Only these two ways are possible:

  1. Ask your user to pick a file or a folder using FilePicker or FolderPicker and then track them in your MostRecentlyUsedList. Then you'll get the permission to access user's permanent file or folder. But you should notice that you must ask your user again to select the same file or folder after uninstalling/installing your app. See the Microsoft docs below to know more about them.

  2. Try to use your cloud server to store the permanent files. This is the method that most network company products do. If you have to power and money to build or rented server, I recommend you to try this way. But it is a waste of time and money to do this in a small personal app.

For conclusion, There is no way to store a permanent file easily like Win32 Desktop Application.

Upvotes: 1

Igor Kulman
Igor Kulman

Reputation: 16361

Not without the user's consent. You will have to implement a save / load functionality to ask the user where to save the file (like Document) and then to select the file to restore.

Upvotes: 5

Related Questions