private void button37_Click(object sender, EventArgs e) // load settings { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "XML Files|*.xml"; openFileDialog1.Title = "Select Settings File"; if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { strXmlPath = openFileDialog1.FileName; // needed for deserialization to generate absolute paths using (FileStream stream = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read)) { int size = (int)stream.Length; // Returns the length of the file byte[] data = new byte[size]; // Initializes and array in which to store the file stream.Read(data, 0, size); // Begins to read from the constructed stream AllButtonInfo allInfo = new AllButtonInfo(); allInfo = AllButtonInfo.Deserialize(System.Text.Encoding.Default.GetString(data), strXmlPath); buttonInfo.Clear(); buttonInfo = allInfo.buttonInfo; // update the labels for (int i = 0; i < buttonInfo.Count(); i++) { ShowLabels(buttonInfo[i].strKey.ToLower(), buttonInfo[i].strLabel, buttonInfo[i].strLabel_ShiftKey); } } //buttonInfo.Add(new ButtonInfo //{ // strKey = ((Button)sender).Text.ToLower(), // strLabel = strNewLabel, // strLabel_ShiftKey = strNewLabel_ShiftKey, // uriSoundFile = uriNewSoundFile, // uriSoundFile_ShiftKey = uriNewSoundFile_ShiftKey, //}); } }