It is easy to have your app settings placed in an XML file and then use it
in your application. I will show you an example:
First you need the config file. In my case it is appname.exe.config. You
will have to add a application configuration file to your project in order
to get it. Just call the file anything you like. I used app.config.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="frmMain.Text" value="Application name ver 2" />
<add key="frmConfig.Text" value="Configuration" />
</appSettings>
</configuration>
In the XML file above you see that i have 2 forms. The text that will appear
in the top of each form is placed in the config file. Now lets have a look
at the code that is using this "setting".
AppSettingsReader configurationAppSettings =new AppSettingsReader();
appName = ((System.String)(configurationAppSettings.GetValue ("frmMain.Text",
typeof(System.String))));
Thats it. As you can see i set an variable appName = the setting from the
XML file. This can easily be passed on to your form.text or anything you
want. Remember to include "using System.Configuration"
Best regards
Trond
"Egil Hansen" <eg**@dailyrush.dk> wrote in message
news:10*********************@z14g2000cwz.googlegro ups.com...
Hi
I need to pass 5-6 simple settings to a console program I'm writing. I
thought about putting them in a simple .ini file or a .xml file. I'm
also thinking about simply passing them to my program as commanline
arguments, that would be a rather long command to type in though, but
it would work.
Anyway, being a newbie at C#, how do I do either best?
Best regards,
Egil.