469,342 Members | 5,939 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,342 developers. It's quick & easy.

read app.config

I have the following XML file named (applicattion.exe.config):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<AppSettings>
<add key = "PathBD" value = "c:\project\data\maco.mdb" />
</AppSettings>
</configuration>
Can anyone send me the code for reading value of 'PathDB' please,
tanks
Nov 21 '05 #1
4 20319
Sure Carlos,

Import System.Configuration
directorypath = ConfigurationSettings.AppSettings("PathDB")

OR

directorypath =
System.Configuration.ConfigurationSettings.AppSett ings("PathDB")

Hope that helps.
Kevin

"Carlos AZ" <Ca******@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
I have the following XML file named (applicattion.exe.config):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<AppSettings>
<add key = "PathBD" value = "c:\project\data\maco.mdb" />
</AppSettings>
</configuration>
Can anyone send me the code for reading value of 'PathDB' please,
tanks

Nov 21 '05 #2
You might like to try a DotNet DLL, which can read / write / modify /store
the Key-Value tags on-fly with many more features, on:
www.aspsimply.com/vbnet/protool.aspx

"Carlos AZ" <Ca******@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
I have the following XML file named (applicattion.exe.config):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<AppSettings>
<add key = "PathBD" value = "c:\project\data\maco.mdb" />
</AppSettings>
</configuration>
Can anyone send me the code for reading value of 'PathDB' please,
tanks

Nov 21 '05 #3
Hi,

Do you mean writing the App.Config file? This is considered bad practice, if
you need to modify the App.Config file within the application there is a
problem with the design.

Microsoft recommends to write using your own serialized object.

Hope this helps to understand .NET arch.
Salva
"Kevin" wrote:
You might like to try a DotNet DLL, which can read / write / modify /store
the Key-Value tags on-fly with many more features, on:
www.aspsimply.com/vbnet/protool.aspx

"Carlos AZ" <Ca******@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
I have the following XML file named (applicattion.exe.config):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<AppSettings>
<add key = "PathBD" value = "c:\project\data\maco.mdb" />
</AppSettings>
</configuration>
Can anyone send me the code for reading value of 'PathDB' please,
tanks


Nov 21 '05 #4
I'm not wanting to ignite a huge debate on this, but it seems to me that
NOT using [as in reading/writing/updating] the App.config file seems
counter-productive. If the INI file is considered deprecated, and practice
of using the Registry is frowned upon, they why not use the config file to
it's full potential? I'm writing a commercial application at the moment
that takes into considertation two things:

1. A user WANTS to customize a tool for their particular habits/needs
2. If the customized settings get wiped, then a default set of applications
will be needed.

To that end this is the solution that I'm following:
I've encapsulated methods for AppConfig and xml
serialization/deserialization of application settings into a couple
classes. ClassA is the Configuration manager, and ClassB is the xml
serializer/deserializer. All this is well and good, but in the event that
settings are wiped, the application simply replaces the config file with a
default copy that it stores as a resource (defaultsettings.xml) in the exe.

In my experience a simple solution like this is more than enough to deal
with business & IT requirements as well as cater to a user's needs.

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Karthikesh Raju | last post: by
2 posts views Thread by MrFile | last post: by
1 post views Thread by vkrasner | last post: by
4 posts views Thread by Chris V | last post: by
4 posts views Thread by brent | last post: by
10 posts views Thread by NuB | last post: by
3 posts views Thread by Brett Romero | last post: by
9 posts views Thread by =?Utf-8?B?TWlrZQ==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.