Helemaal iets anders genomen dan ConfigurationSettings: iets dat IsolatedStorage heet, en waar ik nog nooit van gehoord had. Ik weet zelfs niet precies waar dat ding zich fysiek bevindt, maar het is wel verrekte handig:

1) Een Hashtable maken waarin de settings gaan komen:

Hashtable settings = new Hashtable();
   settings[“UserName”] = “SomeValue”;
   settings[“Preference1”] = SomeOtherValue;

2) IsolatedStorage en zijn formatters gebruiken om de waarden op te slaan:

private void SaveOptions(Hashtable values)
 {
  IsolatedStorageFile isoFile =
System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope.
Assembly | IsolatedStorageScope.User, null, null);
  IsolatedStorageFileStream stream = new
IsolatedStorageFileStream(“mysettings.dat”, System.IO.FileMode.Truncate);
  System.Runtime.Serialization.IFormatter formatter = new
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

  formatter.Serialize(stream, values);
  stream.Close();
  isoFile.Close();
 }

3) En op deze manier weer inlezen:

private Hashtable LoadOptions()
 {
  IsolatedStorageFile isoFile =
System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope.
Assembly | IsolatedStorageScope.User, null, null);
  IsolatedStorageFileStream stream = new
IsolatedStorageFileStream(“mysettings.dat”,
System.IO.FileMode.OpenOrCreate);
  Hashtable setttings = null;
  System.Runtime.Serialization.IFormatter formatter = new
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
  if (stream != null && stream.Length > 0)
  {
   try
   {
    settings = (Hashtable)formatter.Deserialize(stream);
   }
   catch
   {
   }
  }

   if (settings == null) return new Hashtable();
  stream.Close();
  isoFile.Close();
  return settings;
 }