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 "***"
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 "***"
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.AppS ettings 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
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.