Read a config file

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi,

I started developing an .net compact framework application (C#) and I have
the
following question:
I want to read / write a config-file (xml or ini) from the directory where
the
application resides on the pocket pc. (like readprofilestring in VB, C++)
Can someone help send me a code snippet or a like where I can find
a sample ?



Thanks in advance,
Chris
 
Hello,

you can do it with the OpenNETCF.Configuration Namespace of the smart
device framework from opennetcf.org.
The name of the File has to be yourApplicationName.exe.config with folowing
structure:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="key1" value="value1" />
<add key="key2" value="value2" />
....
</appSettings>
</configuration>

In your application you can use the config-File like folowing code:

string key1=OpenNETCF.Configurations.ConfigurationSettings.AppSettings
["key1"];
....

Regards,

Johanna
 
While not specific to the CompactFramework, you might also want to read the
Advanced Basics column ("Remember User Information in Visual Basic .Net")
that appears in this month (April) issue of MSDN Magazine.

Richard Rosenheim
 
Back
Top