>I am developing a windows .NET apps to be used in several countries with
different languages and I want to use a configuration file to retrieve the
fields in the right language depend on the selected country.
I saw that on a web apps but I am not sure if I can do the same on a win apps.
Add a straight text file called "app.config" to your project - call it
just that - nothing else. It will be copied to your compile output
directory and renamed to "myapp.exe.config" by the VS.NET IDE for you.
The app.config file has a clear structure - you can read up about it
on MSDN. Basically, you can either use just the standard <appSettings>
section, to store a few select entries, or you can define your own
custom configuration section (of standard type), or you can even write
your own custom configuration section handler to handle specific
configuration settings.
The info in the app.config file is XML - you need to adhere to all XML
rules and stuff.
Here's a sample app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Default Language" value="en-US" />
<add key="FieldNames" value="fieldnames.txt" />
</appSettings>
</configuration>
To read those values, add the "System.Configuration" namespace to your
using clause, and then use
string sDefaultLanguage = ConfigurationSettings.AppSettings["Default
Language"];
string sFieldNames =
ConfigurationSettings.AppSettings["FieldNames"]
As I said - I would keep the number of entries low - a few, a few
dozen at most - not more.
Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Berne, Switzerland m.scheuner -at- inova.ch