SDF Sample: Using AppSettings

SDF 2.2 has a new namespace called OpenNETCF.AppSettings.  We created this group of classes for those times when you’d like to be able to retrieve and store values in an XML settings file.  Here’s a quick peek at how it might be used:

AppSettings settings = new AppSettings(“\MyApp\ApplicationSettings.xml”);

if (!settings.Groups.Contains(“MyGroup”))
    SettingGroup group = settings.Groups[“MyGroup”];
    group.Settings.Add(“BoolSetting”, true);
    group.Settings.Add(“IntSetting”, 21);
    group.Settings.Add(“StringSetting”, “hello”);


// update a setting
settings.Groups[“MyGroup”].Settings[“IntSetting”].Value = 42;

// save back to the file

string myValue = settings.Groups[“MyGroup”].Settings[“StringSetting”].Value
bool myOtherValue = settings.Groups[“MyGroup”].Settings[“BoolSetting”].Value

2 thoughts on “SDF Sample: Using AppSettings”

  1. I can’t find class AppSettings in OPENNETCF.AppSettings namespace….

    Where can i get more examples on OPENNETCF.AppSettings and OPENNETCF.Configuration namespaces?

    Thanks in advance!


  2. Hello! I Found your blog recently and the namespace to do this has changed to OpenNETCF.AppSettings.SettingsFile … Then the example works fine 🙂 Thanks!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s