We help IT Professionals succeed at work.
Get Started

c# Solution when keys in web.config can increase

Last Modified: 2016-05-18
Hi Experts,

I can have any number of following keys in web.config

<add key="WebServer1Logs" value="C:\meetDinesh"/>
<add key="WebServer2Logs" value="C:\meetDinesh"/>
<add key="WebServer3Logs" value="C:\meetDinesh"/>
<add key="WebServer4Logs" value="C:\meetDinesh"/>

The key format will remain same i.e. next will be WebServer5Logs

I want to read every key using some way so if more keys are added in future, I don't need to change the c# code to read them.

I believe this can be done with Regex can you share that regex.

or some other way also exists.
Watch Question
ste5anSenior Developer
This problem has been solved!
Unlock 3 Answers and 7 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE