locked
[UWP][C#] How to save app data/settings to SharedLocalFolder RRS feed

  • Question

  • Good Day,

    I found this thread on how to share apps data between users and it is really helpful : Sharing data

    I managed to save my sql db to save and retrieve it from SharedLocalFolder , not in LocalState

    but i want the settings : 

    _appSettings = new AppSettings(SettingsService.Create(SettingsStrategies.Local, nameof(AppSettings)));

    to be saved and read in SharedLocalFolder too.
    but there is no SettingsStrategies.Shared , what is the other way so I can save it to SharedLocal ?

    NOTE: I installed the certificate to local machine for all users , and manually installed the app package to different users (cause still searching how to install uwp apps for all users)

    Thanks,
    NicoTing

    • Edited by NicoTing Friday, March 3, 2017 1:40 AM
    • Edited by David_FF Friday, March 10, 2017 1:54 AM title tag
    Thursday, March 2, 2017 7:32 AM

All replies

  • I'm not sure what certificate you talking about. But afaik there is no shared settings. If you wan to share that setting you have to save it in you own file to SharedLocalFolder .

    Please remember to mark the replies as answers if they answered your question!

    Thursday, March 2, 2017 11:25 PM
  • @bitdisaster

    Ok thank you , but how about the app settings (not localsettings) and localcache?

    we have a : SettingsStrategies.Local , SettingsStrategies.Roam, SettingsStrategies.Temp ,
    but we dont have SettingsStrategies.SahredLocalFolder.

    how can i save it in Shared?



    • Edited by NicoTing Friday, March 3, 2017 1:22 AM
    Friday, March 3, 2017 1:08 AM
  • You can't. There is no concept of SharedSettings. However, you could use the same strategy you use for your DB.

    StorageFile file = await folder.CreateFileAsync("MySharedSettings.txt"); 
    await FileIO.WriteTextAsync(file, "allowedRolesKey=stockAllowedRoles");


    Please remember to mark the replies as answers if they answered your question!

    Friday, March 3, 2017 1:33 AM
  • Thank you , Ive updated the Question , its more clear now , can you please see if it makes sense to you

    Thanks
    Friday, March 3, 2017 1:37 AM
  • Well. Your question still indicates that you want a shared setting of some sort. That is not provided out of the box. The only way I can think of is saving your setting into a file in the SharedFolder.

    Please remember to mark the replies as answers if they answered your question!

    Friday, March 3, 2017 5:55 PM
  • @bitdisaster 

    Ok , Im sorry , but how is that? 
    how can I save/create/store the app's Settings.dat to other location?

    Thanks

    • Edited by NicoTing Monday, March 6, 2017 1:20 AM
    Monday, March 6, 2017 12:59 AM
  • Good Day,

    is there a way to save my settings on different location 
    I have a code : 

    _appSettings = new MyAppSettings(SettingsService.Create(SettingsStrategies.Local, nameof(MyAppSettings)));
    that interface settings have bool , string , int , etc.
    it stores the settings of my app , and it is stored in : 
    C:\Users\%username%\AppData\Local\Packages\<AppPackage>\Settings\settings.dat

    I want it to save in the app SharedFolder , how can i create my settings to my SharedFolder location?

    NOTE: I want all machine users to have same settings on my app , there is a a thread how to do that , and I was able to do it on my db , different users shares one db , but not settings
    thread: Sharing data between users of a Universal App





    • Edited by NicoTing Tuesday, March 7, 2017 2:21 AM
    • Merged by David_FF Wednesday, March 8, 2017 3:15 AM same issue
    Tuesday, March 7, 2017 1:01 AM
  • Hi NicoTing,

    The settings.dat file is used for the LocalSettings and RoamingSettings. As bitdisaster said, you need to create a file in SharedLocalFolder for shared settings.

    Best Regards,
    David



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 8, 2017 12:37 PM
  • @NicoTing,

    You may need to put your data to shared locations like Document library to store your setting if you want it to be public to all users in a machine.

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 17, 2017 5:33 AM
  • @Barry

    Can you please provide an example?

    Thanks
    Wednesday, March 29, 2017 5:57 AM