我正在寻找一种将c# DateTimePicker
与任务计划程序库。翻阅文件并没有得到启发我的脑海里。有人找到解决这种问题的办法了吗?
通常通过:
初始化new TaskService().AddTask
("ITW Backup", new TaskTriggerType { Once },
new ExecAction("Backup.exe", "C:\Backup\ini.ini", null));
但是,即使是文档中的{once}
语句也让我感到困难。
解决方案相当简单:)
dateTimePicker1.Format = DateTimePickerFormat.Time;
TaskService ts = new TaskService();
TaskDefinition td = ts.NewTask();
Trigger t = new TimeTrigger();
t.StartBoundary = System.DateTime.Now.Date +this.dateTimePicker1.Value.TimeOfDay;
td.Triggers.Add(t);
//string path1 = Path.GetDirectoryName(Application.ExecutablePath);
string path1 = Desktop + @"DesktopReleaseITWBackup.exe";
td.Actions.Add(new ExecAction(path1, null, null));
ts.RootFolder.RegisterTaskDefinition("ITWBackup", td);
ts.BeginInit();