문제

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