0

I want to write a key and multiple values in app.config, so that depending on the value a method is run.

for example:

let the key be "syncMode" and values to be kept are "syncAll"/"syncYest"

If the value is set as syncAll, complete data sync should happen in the main program and if syncYest is set, then only yesterday's data should be sync.

How can i write this in App.config?

0x49D1
  • 8,505
  • 11
  • 76
  • 127
ASN
  • 1,655
  • 4
  • 24
  • 52
  • So what is the problem? Are you getting any errors? – Andrew Savinykh Apr 26 '16 at 07:15
  • Hi andrew.. No i didnt get any errors.. i just wanted to know if that is possible and if yes, how? – ASN Apr 27 '16 at 00:55
  • But you are saying in the comment to an answer that you tried that ("*I think thats the best way for my scenario.. i tried the same..*"). So what went wrong? What did not work when you tried? Unless you tell us it's really hard to guess. – Andrew Savinykh Apr 27 '16 at 02:19

2 Answers2

1

Based on your requirement this looks like a simple case of single name and single value.If you want "Complete data sync in the main program" set value of key syncMode = "syncAll".Otherwise if you want "yesterdays data to sync" use syncMode = "syncYest"

shbht_twr
  • 505
  • 3
  • 14
0

You can create a custom configuration section for this. There is already a SO Post related to this. Additionally, you can also read the official MSDN page.

Community
  • 1
  • 1
DHN
  • 4,807
  • 3
  • 31
  • 45
  • thanks DHN :). I think creating a custom configuration is for more complex situations than this. thanks for sharing the post. But for now i just kept it simple in App.config – ASN Apr 27 '16 at 00:56
  • @ASN: Definitely a wise decision, since the overhead is huge. But you're welcome. – DHN Apr 27 '16 at 07:49