bman9111
asked on
c# configuration file
I have a c# program that I want to store configurations in a file and have my program read it. What would a coding look like for something like this?
ASKER
I am using 2005.
Please explain how I can do this. What I want is a stand alone file that is in the same directory as the exe so that I could go into and change the settings versus having to go into the code and recompile.
Please explain how I can do this. What I want is a stand alone file that is in the same directory as the exe so that I could go into and change the settings versus having to go into the code and recompile.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is a simple example:
// C#
NameValueCollection AllAppSettings = ConfigurationManager.AppSe
Console.WriteLine(AllAppSe
Put the following in your App.Config file
<appSettings>
<add key="ApplicationName" value="Demo Application"/>
<add key="ApplicationVersion" value="2.0.0.1"/>
<add key="UserFirstName" value="John"/>
<add key="UserLastName" value="Public"/>
</appSettings>
More detail please see System.configuration namespace
http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx
The other option is to use new project settings feature in VS2005. (VS generates a set of class to manage settings)
Example
http://www.codeproject.com/vb/net/appsettings2005.asp