I want the user to be able to chose the time the ClearFiles()
function will get called every day. The timer executes at the time the user selects but never correctly fires after the x amount of minutes / hours specified.
Code:
DateTime nowTime = DateTime.Now;
DateTime deleteTime = new DateTime(nowTime.Year, nowTime.Month, nowTime.Day,
FileFilter.deleteTime.Hour, FileFilter.deleteTime.Minute, 0);
if (nowTime > deleteTime)
{
deleteTime = deleteTime.AddDays(1)
}
double tickTime = (deleteTime - nowTime).TotalMilliseconds;
aTimer = new Timer(tickTime);
aTimer.Elapsed += (s, e) => ClearFiles(FileFilter.pathName);
aTimer.Start();