public void saveNewSettings(string filename) { stringOfRSFileNames = StringCollectionConverter.convert(defaultRSFileNames); try { ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); fileMap.ExeConfigFilename = filename; // relative path names possible // Open another config file Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); // You need to remove the old settings object before you can replace it config.Sections.Remove("GraphSynthSettings"); // with an updated one config.Sections.Add("GraphSynthSettings", this); // Write the new configuration data to the XML file config.Save(); } catch (Exception e) { MessageBox.Show("The configuration file did not save becuase of error: " + e.ToString(), "Error Saving config file.", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value.GetType() == typeof(string)) { return(StringCollectionConverter.convert((string)value)); } else { return(null); } }
private void setUpRuleSetList(string names) { defaultRSFileNames = StringCollectionConverter.convert(names); for (int i = defaultRSFileNames.Count; i != 0; i--) { if (defaultRSFileNames[i - 1].Equals("xml")) { defaultRSFileNames.RemoveAt(i - 1); } else if (!defaultRSFileNames[i - 1].EndsWith(".xml")) { defaultRSFileNames[i - 1] += ".xml"; } } if (defaultRSFileNames.Count == 0) { defaultRSFileNames.Add(""); } }