Bear in mind this is a bit difficult for me to explain.
I currently have a set of check boxes in my settings form and I might add more in later updates. I want to save these to a file in the general format of:
false
true
false
etc etc...
But what happens when an update adds a check box or two? I try to load the file's boolean values into them with:
string [] array = File.ReadAllLines(<FILE>); checkboxOne.Checked = bool.Parse(array[0]) checkboxTwo.Checked = bool.Parse(array[1]) //etc etc...
But when it gets to the new check boxes, for which there is no line in the file, it will throw an IndexOutOfBoundsException because the file has x minus number-of-boxes-added lines and thus so does the array. Example:
5 old boxes, 3 new. the file and array count 5, so when the program reaches index 5 (the sixth and nonexistent line), exception.
Is there a better way to implement this to allow for a growing set of check boxes? Should I constantly check if the array length is less and resize as necessary?






