473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 20553
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Karthikesh Raju | last post by:
Hi All, i am wondering about the best way to read in a configuration file that goes like: ########### source_dir = '/home/karthik/Projects/python' data_dir =...
2
by: MrFile | last post by:
I added an app.config file to my application. (c#.net component dll) <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="username" value="xx" /> <add...
3
by: Mustaq | last post by:
Hi, How to read same config file from different application? I have 4 application in VB.NET, all are using different app.config files. NOW I need all to read only one config file, how can I do...
1
by: vkrasner | last post by:
It works with VS2003 and does not in VS2005: in VS2003 : string sMyvalue = ConfigurationSettings.AppSettings; in VS2005 (does not work!!) string sMyvalue = ConfigurationManager.AppSettings; ...
4
by: Chris V | last post by:
I'm having a problem deploying my ASP.NET application to a WIN2k server. (IIS5 .NET 1.1) When I try to access ConfigurationSettings.AppSettings("WhateverValue") I get an "Object reference not...
4
by: brent | last post by:
Currently our application is reading from the web.config, and retrieves a section, "softwareRequirements". Because the section will begin to grow dramatically, I'd like to place it in the SQL...
10
by: NuB | last post by:
I'm creating a C# class file(DLL) that will be used by an asp.net application. In the DLL I want to read a web.config, or app.config file so some information can change without having to go into...
5
by: Sridhar | last post by:
Hi, I have created a project which contains classes to read the data from the database. This project has an App.Config file which contains the SqlConnection String. when this code is called from...
3
by: Brett Romero | last post by:
I'd like to use some of the techniques discussed here for reading a config file in .NET 2.0: http://msdn.microsoft.com/msdnmag/issues/06/06/ConfigureThis/default.aspx Here's my app.config...
9
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. Is it programatically possible in VB.NET to read the contents of web.config's <customErrorselement? I looked at using ConfigurationSettings.AppSettings, but that doesn't work. I need to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.