It seems that your code generate access violation exception and your service will stop..
1.You forgot to manage the exceptions into your service. You should mange them in the way that even if exception will occur your service will remain up and running; and also your should write notification into the Windows Event Log, at least the exceptions data.
You could find details about exception management, including some util class for writing notifications into the Windows Event Log into my next article:
MVC Basic Site: Step 2 - Exceptions Management[
^]
2.To solve the access violation exception, after installation, you have to start your windows service by using a user that have
rights
to the main folder that contains the files that you are trying to manage.
Note that in the administrator management window, when you start a service, you have the possibility to provide the credentials (user name and password) for existing users of the computer.