C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to read configuration file of another application?


Posted Date: 12 Oct 2006    Resource Type: Articles    Category: WCF/Webservices

Posted By: Tony John       Member Level: Gold
Rating:     Points: 10



Developers often need to access the web.config file or the application configuration file of one application from another application. Upto Visual Studio 2003, there was no direct way to do this. Developers used to treat the config file as a xml file and parse the xml using the XML classes.

With Visual Studio 2005, it is very simple to load the config file of any application.

The below sample show how to read the web.config file located in the folder C:\SomeOtherApp. This folder can be any location and not required to be a folder of a web application.

Here is the sample code to read the config file from any location in your computer:




System.Configuration.ExeConfigurationFileMap map = new System.Configuration.ExeConfigurationFileMap();

map.ExeConfigFilename = "C:\\SomeOtherApp\\web.config";

System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(map, System.Configuration.ConfigurationUserLevel.None);

string name = config.AppSettings.Settings["KeyInOtherApp"].Value;






Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Understanding Security Aspects of .Net Framework – Part 1 of 5
Previous Resource: Microsoft patterns and practices, a faster approach towards developing applications in .net
Return to Discussion Resource Index
Post New Resource
Category: WCF/Webservices


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

budget conference call

Contact Us    Privacy Policy    Terms Of Use