简体   繁体   中英

Save and recall multiple Properties.Settings.Default objects?

To make things a tad simpler in my C# application, I decided to save all user style changes using the Properties.Settings properties, which works as expected.

But I liked the style change aspect of my app so much, and it is so important to the usage, that I have now decided to have savable and loadable style files( MyStyle.xxx ) for the user to save and reload. But as I have never used these user settings before, I am unsure of how to duplicate and save this object. Can it be done simply, or can I maybe write these objects to serialized XML? What is the common approach?

PS I tried researching this topic but because it is so closely related to just saving user settings, all I could find was questions about saving user settings.

This is sort of sketchy but it has worked for me in the past and seems to be a pretty decent solution..

Firstly, create a list of settings you want and some default values.

Then create some JSON-esque format for your data and save in the setting as a string. From there you can jsut copy paste this template and make say 3 more string in your settings file for a total of 4 strings with the same JSON stuff in it.

It's a bit of a fuss parsing that info in and out but if you do set it up in JSON format then it shouldn't be too hard.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM