How to create a windows service to schedule some task like delete the files on a certain folder? [closed]

谁说胖子不能爱 提交于 2019-12-11 14:12:58

问题


Hi i am relatively new to windows service. I want to create a schedule task that will go through certain folder like c://dev/ and delete the files that are created between some date/time. How can i achieve this?Any help really appriciated...


回答1:


Check this for 'forfiles' command: Batch file to delete files older than N days

Then you can store a command of your wish into a .bat file and set Windows Task Scheduler to run that file.

If you want to do it using Windows Services, check this: http://www.c-sharpcorner.com/blogs/7224/deleting-a-file-after-7-days-using-windows-services.aspx




回答2:


If you want to run a custom scheduler from a windows service, you can try out the Quartz open source scheduling service library. You can then define CRON Triggers to fire as and when you need. I have used this in a windows service developed in C# and its excellent. The tutorials will quickly get you up and running.

For the windows service itself, you can have a look at the article by @mostruash above or even this. You can easily customize the base templates as per your wishes.



来源:https://stackoverflow.com/questions/15353160/how-to-create-a-windows-service-to-schedule-some-task-like-delete-the-files-on-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!