Question

How would I go about coding my C# console program to look to a different directory for its app.config file? I would like the config file to sit in the program files folder but have the exe inside the startup folder.

Was it helpful?

Solution

You can create a new application domain, and configure it to use configuration file other than default one. Here is how to create and configure app domain :http://msdn.microsoft.com/en-us/library/c8hk0245.aspx.

Here is config file property. http://msdn.microsoft.com/en-us/library/system.appdomainsetup.configurationfile.aspx

After you created a domain you can invoke DoCallBack on the created app domain http://msdn.microsoft.com/en-us/library/system.appdomain.docallback.aspx to start your application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top