I have a text file which is continuously getting updated from the server data and as per my requirement, I have to create a new text file every midnight. As soon as the date changes, I need to write data from the server into the newly created text file. The server side text file contains date-wise data like this:

1/1/2014   234  34  456788889989 23 
1/1/2014   234  34  456788889989 23 
1/1/2014   234  34  456788889989 23 
2/1/2014   234  34  456788889989 23 
2/1/2014   234  34  456788889989 23 
2/1/2014   234  34  456788889989 23 
3/1/2014   234  34  456788889989 23 
3/1/2014   234  34  456788889989 23 
3/1/2014   234  34  456788889989 23 

I want to run this program as a windows service which will execute every midnight and will do the above work.

I want to ask if this is possible with windows service.Can i use a timer to do this task?

有帮助吗?

解决方案 2

A scheduled task is probably more appropriate, see e.g. http://weblogs.asp.net/jgalloway/archive/2005/10/24/428303.aspx for a discussion.

To set up a scheduled task, just create a console application that does your job.

其他提示

It is perfectly possible to use a service for this. But you might consider using the windows task scheduler for this instead and let the scheduler run a script or a small command line application that does what you want at every midnight.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top