private void RemoveProgram_Button_Click(object sender, RoutedEventArgs e) { if (SelectedProgram != null) { VPNPrograms.Remove(SelectedProgram); SavePrograms(); } }
private void SavePrograms() { XmlSerializer serializer = new XmlSerializer(typeof(List <string>)); using (TextWriter writer = new StreamWriter("VPNetMonProgramsList.xml")) { serializer.Serialize(writer, VPNPrograms.ToList()); writer.Close(); } }
private void AddProgram_Button_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Multiselect = false; bool?userClickedOK = openFileDialog.ShowDialog(); // Process input if the user clicked OK. if (userClickedOK == true) { VPNPrograms.Add(openFileDialog.FileName); SavePrograms(); } }
private void LoadPrograms() { XmlSerializer serializer = new XmlSerializer(typeof(List <string>)); try { using (TextReader reader = new StreamReader("VPNetMonProgramsList.xml")) { foreach (string prog in (List <string>)serializer.Deserialize(reader)) { VPNPrograms.Add(prog); } reader.Close(); } } catch (Exception ex) { } }