如何创建 Windows 服务来安排一些任务,例如删除某个文件夹中的文件? [英] How to create a windows service to schedule some task like delete the files on a certain folder?

查看:13
本文介绍了如何创建 Windows 服务来安排一些任务,例如删除某个文件夹中的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Windows 服务比较陌生.我想创建一个计划任务,该任务将通过 c://dev/等特定文件夹并删除在某个日期/时间之间创建的文件.我怎样才能做到这一点?任何帮助真的很感激......

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...

推荐答案

检查 'forfiles' 命令:批处理文件删除超过 N 天的文件

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

然后您可以将您希望的命令存储到 .bat 文件中,并设置 Windows 任务计划程序来运行该文件.

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

如果您想使用 Windows 服务执行此操作,请检查以下内容:http://www.c-sharpcorner.com/blogs/7224/deleting-a-file-after-7-days-using-windows-services.aspx

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

这篇关于如何创建 Windows 服务来安排一些任务,例如删除某个文件夹中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆