Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easiest way to read a config file belonging to another application

Other than using raw XML, is there an easy way in .NET to open and read a config file belonging to another assembly...? I don't need to write to it, just grab a couple of values from it.

like image 338
Matt Avatar asked Oct 27 '08 12:10

Matt


People also ask

How do you read in configuration settings from the application config file?

Add the App. config file to your project. After creating a . NET Framework project, right-click on your project in Solution Explorer and choose Add > New Item. Choose the Application Configuration File item and then select Add.

Where the configuration files are stored in your application?

These config files are typically placed under separate root directory than the rest of application code. For example, in case of Java they are typically under src/main/resources .

What application opens .config file?

The Visual Web Developer program built-in to Visual Studio is used to open and edit this CONFIG file. The Notepad program in Windows works just fine for viewing, editing, and even creating text-based configuration files like this.


2 Answers

Here's MSDN on OpenExeConfiguration.

Edit: link to a how-to on eggheadcafe.com disappeared. Looks like EggheadCafe moved to NullSkull but dropped the article ID's.

like image 163
DOK Avatar answered Sep 27 '22 19:09

DOK


Have you tried ConfigurationManager and OpenExeConfiguration(path)? (in System.Configuration.dll)

like image 22
Marc Gravell Avatar answered Sep 27 '22 20:09

Marc Gravell