473,404 Members | 2,174 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,404 software developers and data experts.

where do I find a config file parser (xml or ini file)?

Hi

I need to pass 5-6 simple settings to a console program I'm writing. I
thought about putting them in a simple .ini file or a .xml file. I'm
also thinking about simply passing them to my program as commanline
arguments, that would be a rather long command to type in though, but
it would work.

Anyway, being a newbie at C#, how do I do either best?
Best regards,
Egil.

Nov 16 '05 #1
5 2024
Hi Egil!

"Egil Hansen" schrieb
I need to pass 5-6 simple settings to a console program I'm writing. I
thought about putting them in a simple .ini file or a .xml file. I'm
also thinking about simply passing them to my program as commanline
arguments, that would be a rather long command to type in though, but
it would work.


INI-Files:
http://www.mentalis.org/soft/class.qpx?id=6

XML-Config-Files:
http://www.palmbytes.de/content/dotnet/optionslib.htm

Cheers

Arne Janning
Nov 16 '05 #2
It is easy to have your app settings placed in an XML file and then use it
in your application. I will show you an example:

First you need the config file. In my case it is appname.exe.config. You
will have to add a application configuration file to your project in order
to get it. Just call the file anything you like. I used app.config.
<?xml version="1.0" encoding="utf-8"?>

<configuration>

<appSettings>

<add key="frmMain.Text" value="Application name ver 2" />

<add key="frmConfig.Text" value="Configuration" />

</appSettings>

</configuration>

In the XML file above you see that i have 2 forms. The text that will appear
in the top of each form is placed in the config file. Now lets have a look
at the code that is using this "setting".
AppSettingsReader configurationAppSettings =new AppSettingsReader();

appName = ((System.String)(configurationAppSettings.GetValue ("frmMain.Text",
typeof(System.String))));

Thats it. As you can see i set an variable appName = the setting from the
XML file. This can easily be passed on to your form.text or anything you
want. Remember to include "using System.Configuration"

Best regards
Trond

"Egil Hansen" <eg**@dailyrush.dk> wrote in message
news:10*********************@z14g2000cwz.googlegro ups.com...
Hi

I need to pass 5-6 simple settings to a console program I'm writing. I
thought about putting them in a simple .ini file or a .xml file. I'm
also thinking about simply passing them to my program as commanline
arguments, that would be a rather long command to type in though, but
it would work.

Anyway, being a newbie at C#, how do I do either best?
Best regards,
Egil.

Nov 16 '05 #3
Thanks a bunch guys, this really helped.

Best regards, Egil.

Nov 16 '05 #4
Hi again Trond.

I finally got around to testing your idea, but I cant get it to work. I
even tried using the same key's and values as you, but still gets an
expection telling me that the key i'm looking for doesnt exists. Can
you help a little more.

Thanks, Egil.

Nov 16 '05 #5
Sure. If you open a form and then go to the forms property you will find
"Dynamic properties". Click on that lil + so that you can see a field called
(Advanced) (still in DynamicProperties). Click on the little button with 3
dots. Now you will se a dialogboks. Scroll a little don and select "Text".
In the textbox at the right part of the dialog you will see a text
"frmName.text". Clik OK and voila you will find that in the app.config file.
When you compile you will see that an additional config file appear. That
will have the name appname.exe.config.
Hope this help. If not please drop me a mail and i'l try to help
Best regards
Trond

"Egil Hansen" <eg**@dailyrush.dk> wrote in message
news:10**********************@c13g2000cwb.googlegr oups.com...
Hi again Trond.

I finally got around to testing your idea, but I cant get it to work. I
even tried using the same key's and values as you, but still gets an
expection telling me that the key i'm looking for doesnt exists. Can
you help a little more.

Thanks, Egil.

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: qqcq6s59 | last post by:
Hi all I am a newbie and I just saw a ongoing thread on Fileprocessing which talks abt config parser. I have writen many pyhton program to parse many kind of text files by using string module and...
5
by: Stephanie Stowe | last post by:
Imagine that I had this <webServices> <soapExtensionTypes> <add type="Microsoft.Web.Services.WebServicesExtension, Microsoft.Web.Services, Version=1.0.0.0, Culture=neutral,...
4
by: alex444 | last post by:
Any help on this error much appreciated. Application works on dev but not on 3d party host server (with useless support). ========================== Server Error in '/' Application....
21
by: Nick Craig-Wood | last post by:
Lance Gamet <lance@gamet.comwrote: I've found http://docs.python.org/lib/module-ConfigParser.html To be easy to use and built in. It makes human readable / editable ..ini - like files. ...
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: 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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.