Task Scheduling using AppConfig settings
<p>I have a config file with the following settings:</p>

<pre><code>&lt;add key ="Mode" value ="Daily"/&gt;

&lt;add key="ScheduledTime" value="16:30"/&gt;
</code></pre>

<p>Based on these values in the config file, I need to schedule the job automatically in my C# program. I have tried this code but it throws an error: </p>

<blockquote>
  <p>When converting string to datetime, parse the string to take the date
  before putting each variable into DateTime object</p>
</blockquote>

<pre><code>TaskService ts = new TaskService()
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "RMATask";

if (ConfigurationManager.AppSettings.Get("Mode") == "Daily")
{
    DailyTrigger daily = new DailyTrigger();
    daily.StartBoundary = Convert.ToDateTime(DateTime.Today.ToShortDateString() + ConfigurationManager.AppSettings.Get("ScheduledTime"));
    daily.DaysInterval = 1;
    td.Triggers.Add(daily);
    td.Actions.Add(new ExecAction(@"C:/Bigdata/bigdatadev/Framework/ConsoleApplication1/bin/Debug/ConsoleApplication1.exe", null, null));
    ts.RootFolder.RegisterTaskDefinition(ConfigurationManager.AppSettings.Get("Tablename"), td);
}
</code></pre>

<p>Any help would be appreciated. Thanks.</p>