For running a batch file on some schedule, you can create your own service, but an already created existing service could suffice. It is already bundled with Windows and enabled; you can use it on different levels. It is called Window Task Scheduler, see
http://en.wikipedia.org/wiki/Windows_Task_Scheduler[
^].
First, you can schedule events using command-line utilities AT.EXE or CSHTASKS.EXE (which is replacing AT.EXE), see:
http://en.wikipedia.org/wiki/At_%28Windows%29[
^],
http://en.wikipedia.org/wiki/Schtasks[
^],
http://technet.microsoft.com/en-us/library/bb490866.aspx[
^],
http://msdn.microsoft.com/en-us/library/windows/desktop/bb736357%28v=vs.85%29.aspx[
^].
And you also can use Window Task Scheduler API, please see:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383614%28v=vs.85%29.aspx[
^],
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383608%28v=vs.85%29.aspx[
^].
To see how can you use it with .NET, see this CodeProject article:
A New Task Scheduler Class Library for .NET[
^].
Now, for reading XML, .NET .FCL provides different classes. Please see my short overview of them:
- Use
System.Xml.XmlDocument
class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^]. - Use the classes
System.Xml.XmlTextWriter
and System.Xml.XmlTextReader
; this is the fastest way of reading, especially is you need to skip some data.
See http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx[^], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^]. - Use the class
System.Xml.Linq.XDocument
; this is the most adequate way similar to that of XmlDocument
, supporting LINQ to XML Programming.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].
However, I doubt that you need to deal with XML files by yourself. Instead, you can use already available serialization. One of the best approaches is using
Data Contract, the easiest to use but most robust way of serialization:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[
^].
Please see my past answers:
How can I utilize XML File streamwriter and reader in my form application?[
^],
Creating property files...[
^].
If, by some reason, you still need to learn Windows Services, please start here:
http://en.wikipedia.org/wiki/Windows_service[
^],
http://technet.microsoft.com/en-us/library/cc783643%28v=ws.10%29.aspx[
^],
http://msdn.microsoft.com/en-us/library/ms685141.aspx[
^].
—SA