473,385 Members | 1,396 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,385 software developers and data experts.

What is the best way to populate an array from a config file.

I have an application that will be accessing an array of ports obtained from
a config file. What would be the best way to do populate the array if the
config file has, say, the following format:

<configuration>
<applicationSettings>
<AppURL server=http://DevAppServer>
<port value="8000"/>
<port value="8100"/>
<port value="8200"/>
</AppURL>
</applicationSettings>
</configuration>
Jun 5 '06 #1
2 2103
I don't believe that will work for appSettings, because you have multiple
identical key names.

You could do
<port values="8000;8100;8200;8300"/>

Then in your code,

string[] portValues ConfigurationSettings.AppSettings["port"].Split(';');
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Thirsty Traveler" wrote:
I have an application that will be accessing an array of ports obtained from
a config file. What would be the best way to do populate the array if the
config file has, say, the following format:

<configuration>
<applicationSettings>
<AppURL server=http://DevAppServer>
<port value="8000"/>
<port value="8100"/>
<port value="8200"/>
</AppURL>
</applicationSettings>
</configuration>

Jun 5 '06 #2
Actually, I was concerned about this in AppSettings as well (which I usually
use for config strings), so I put it into applicationSettings.

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:28**********************************@microsof t.com...
I don't believe that will work for appSettings, because you have multiple
identical key names.

You could do
<port values="8000;8100;8200;8300"/>

Then in your code,

string[] portValues ConfigurationSettings.AppSettings["port"].Split(';');
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Thirsty Traveler" wrote:
I have an application that will be accessing an array of ports obtained
from
a config file. What would be the best way to do populate the array if the
config file has, say, the following format:

<configuration>
<applicationSettings>
<AppURL server=http://DevAppServer>
<port value="8000"/>
<port value="8100"/>
<port value="8200"/>
</AppURL>
</applicationSettings>
</configuration>

Jun 5 '06 #3

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

Similar topics

11
by: alex | last post by:
Hi, I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML....
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 =...
1
by: Grant Hammond | last post by:
I have a callback function that populates a listbox with a list of file names in a folder. This code came from Terry Kreft/Dev Ashish some years ago. I now want to add another column to the list...
5
by: Robert Oschler | last post by:
I am converting a Perl script over to "C" for a potential open source project. I need some open source "C" code that will give me the same functionality of a Perl Style associative array: ...
1
by: Herve MAILLARD | last post by:
Hi, I have to write a software doing the following : - Load a file (containing data) Data will be display in a Treeview and are typed as following Equipement Bloc Tag It could have for each...
41
by: Mountain Bikn' Guy | last post by:
What is the current preferred way to save user preferences in dotnet? Is the registry the right place to do this? Can anyone recommend a good article (or book) for this topic? Thanks.
1
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
0
by: vijendra | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file?I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
12
by: vijayarl | last post by:
Hi All, Thanks in Advance !!!! I have one config file & am reading that file.later i am using one of the value specified in the config file & trying to get the files placed in the directory...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.