Frage

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.

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top