Link to home
Start Free TrialLog in
Avatar of netformx
netformx

asked on

How to read all appSettings (key/val) from config file?

Hi,

I would like to store in Hashtable all appSettings  I have in my config file.

or even better: to store all key/value where key start with "***"

Avatar of bloodredsun
bloodredsun
Flag of Australia image

A Hashtable is a programming object/construct so you must being using a programming language. Which one are you looking to use (although from your comment history it would be more likely to be ASP.net than Java, yes)?
Well, the ConfigurationSettings.AppSettings Property is a NameValueCollection, so  it's a simple matter to iterate over the members, and build a hash table or do anything else you want.  And the NameValueCollection has the GetHashCode method.

See:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemconfigurationconfigurationsettingsclassappsettingstopic.asp
And:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionsspecializednamevaluecollectionmemberstopic.asp

I'm curious why you need to store these in a hash table--they're always accessible by key anyway.  Do you access these so often that performance is an issue?

Regards,
Mike Sharp
Avatar of netformx
netformx

ASKER

I just want all keys tha tstart with some prefix - do you have better idea than put all into hashtable and then iterate and select what you need? (I don't know a way to access key by its prefix, do you?)
ASKER CERTIFIED SOLUTION
Avatar of rdcpro
rdcpro
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial