我正在寻找将C#DateTimePicker
连接到的可能性
任务计划程序库。浏览文档并没有启发
我脑海。是否有人为此类事件找到了解决方案?
通常它由以下内容初始化:
new TaskService().AddTask
("ITW Backup", new TaskTriggerType { Once },
new ExecAction("Backup.exe", "C:\\Backup\\ini.ini", null));
但即使是文档中的{once}
声明也让我很难过。
答案 0 :(得分:0)
解决方案非常简单:)
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 + @"\Desktop\Release\ITWBackup.exe";
td.Actions.Add(new ExecAction(path1, null, null));
ts.RootFolder.RegisterTaskDefinition("ITWBackup", td);
ts.BeginInit();