472,378 Members | 1,148 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,378 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 20483
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.