Read a config file

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
 
J

Johanna via DotNetMonster.com

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
 
R

Richard L Rosenheim

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top