1

I would like to have only one configuration file for all assemblies that are in my solution. So what is the best way to get the path of user.config from an other assembly?

christophrus
  • 1,170
  • 2
  • 14
  • 27
  • You could [add a link](http://blogs.msdn.com/b/jjameson/archive/2009/04/02/linked-files-in-visual-studio-solutions.aspx) to the config file you want to use. – ean5533 Mar 26 '13 at 15:34
  • Already did that, but this generates a seperate user.config in a different folder at runtime. – christophrus Mar 26 '13 at 15:44
  • Ah, I thought you meant that you only wanted one user.config file *at build time*. I didn't realize you wanted one config file at run time as well. Then yes, you'll have to do something like David suggested below. – ean5533 Mar 26 '13 at 15:46

1 Answers1

0

user.config is nothing but a xml file. You can read it with XmlDocument then.

XmlDocument doc = new XmlDocument();
doc.LoadXml("user.config");

XmlElement element = doc.DocumentElement;

XmlAttributeCollection attr_coll = myElement.Attributes;

for (int i = 0; i < attr_coll.Count; i++)
{
    string attr_name = attr_coll[i].Name;
}
David
  • 15,894
  • 22
  • 55
  • 66