我想创建一个每天下午 6 点启动的“DLL”进程。并在文件夹路径上搜索新的 XML 文件。但我现在真的知道如何实现这一点。
这是使用从第一天下午 6 点开始的“计时器”的唯一方法。并有这样的24小时间隔?
System.Timers.Timer _myTime = new System.Timers.Timer();
private bool SetTimer(double intervall)
{
try
{
_myTime.Interval = intervall;
_myTime.Elapsed += _myTime_Elapsed;
_myTime.Enabled = true;
return true;
}
catch (Exception)
{
return false;
}
}
void _myTime_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
//do something to search for new XML files and copy them to a new file or so....
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
最佳答案
您不需要将调度实现到程序的逻辑中。 只需编写并发布您的代码即可。现在您可以使用Windows任务计划程序来实现计划。只需选择必须执行哪个程序以及何时执行。
关于c# - DLL 进程每天在同一时间启动以检查文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30341784/