I need your help.
i want To create a c# class which works together with a config file placed in the /config/ folder (ie. /config/newfolder/DateFolder.config.)
i want to create a config file in this format dynamically..
how to dynamically create elements in config file.(Example here is: DateFolders,DateFolder,2009,September,5)
<2009>
<5>Page5>
2009>

Master BillaRank #2,229 · 630 reputationPosted Sep 8, 2009, 6:19 AM EDT
You can read above file using XML.If not custom config you can read using ConfigurationManager class.
i assume this a custom XML file.
using System; using System.Xml; namespace ReadXMLfromFile { /// /// Summary description for Class1. /// class Class1 { static void Main(string[] args) { XmlTextReader reader = new XmlTextReader ("config.xml"); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. Console.Write(""); break; case XmlNodeType.Text: //Display the text in each element. Console.WriteLine (reader.Value); break; case XmlNodeType.EndElement: //Display the end of the element. Console.Write(""); break; } } Console.ReadLine(); } } } Thank youRoei BarRank #1,271 · 1.4K reputationPosted Sep 8, 2009, 12:13 PM EDT
like this
//Load Source ExeConfigurationFileMap map = new ExeConfigurationFileMap(); map.ExeConfigFilename = "source.config"; Configuration source = ConfigurationManager.OpenMappedExeConfiguration(map,ConfigurationUserLevel.None); //Load Target map.ExeConfigFilename = "target.config"; Configuration target = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);target.AppSettings.Settings and source.AppSettings.Settings hold the AppSettings KeyValueCollection
asif khan3 reputationPosted Sep 8, 2009, 8:52 PM EDT