How do I store an array of a particular type into my settings file?
- by joebeazelman
For some reason, I can't seem to store an array of my class into the settings. Here's the code:
var newLink = new Link();
Properties.Settings.Default.Links = new ArrayList();
Properties.Settings.Default.Links.Add(newLink);
Properties.Settings.Default.Save();
In my Settings.Designer.cs I specified the field to be an array list:
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::System.Collections.ArrayList Links {
get {
return ((global::System.Collections.ArrayList)(this["Links"]));
}
set {
this["Links"] = value;
}
}
For some reason, it won't save any of the data even though the Link class is serializable and I've tested it.