C# Windows Service - Read from ini or App.config file

Viewed 8294

I have one Windows Polling Service to send an automatic email each 10 minutes. I use Thread.Sleep(new TimeSpan(0, 10, 0)); to sleep the thread for 10 minutes, which is hard coded right now.

To avoid hard coding, I have tried App.config which was not successful. I want to move the hard coding to some .ini files. How can I read .ini file from C# Windows Service.

EDIT: I try the below code to read from my windows service. string pollingInterval = (string)new AppSettingsReader().GetValue("PollingInterval", typeof(string)); Gives the below error. Configuration system failed to initialize

2 Answers
Related