Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to check a daily log file for errors. I have created a C# class with one method that checks the file and sends an e-mail with the answer. I want the system to run this class automatically every night.

Any help would be greatly appreciated.
Posted

The easiest an simplest way would be to employ the Windows Task Scheduler[^] service.

Build your class into a console application, then use the Task Scheduler to schedule it. This can be done using the GUI (Control Panel → Administrative Tools → Task Scheduler), or at the command line using <a href="http://en.wikipedia.org/wiki/At_(Windows)">at</a>[^] or <a href="http://en.wikipedia.org/wiki/Schtasks">schtasks</a>[^]. The latter is much more flexible.

If you would like to do this programatically, you want to develop a Windows NT Service[^]. This is a much bigger task.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 5-Oct-11 11:22am    
Agree, using the Task Scheduler service is probably the best way, my 5.
Writing a whole Windows Service for this task could be a big overkill for this particular problem, good to mention though.
--SA
Create a console app project using your class and schedule it on your server.

Here you will find an guide on how to schedule a task:
http://support.microsoft.com/kb/308569[^]

And here you can start with a creating a console app:

http://msdn.microsoft.com/en-us/library/0wc2kk78(v=vs.90).aspx[^]


Cheers!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900