Hi,
Window Service is a seperate application all together. And FTP Server data reading is equally is seperate program.
What we need to do is that from the OnStart event of the Window Service, we need to invoke the FTP program.
You can refer this article as ur reference ( http://www.codeproject.com/KB/IP/SimpleFTPDemo.aspx ) for accessing the FTP.
The design of ur full program will be something as below
Have an Interface say IFTPService as under
public interface IFTPService
{
void Start();
void Stop();
}
And have a concrete class say FTPService that will implement the interface as under
public class FTPService : IFTPService
{
public void Start()
{
//code for FTP access
}
public void Stop()
{
//Perform the operation while the service will be close
}
}
Now from the window service invoke the Start and Stop method of the interface as under
public partial class FTPWindowService : ServiceBase
{
IFTPService iservice;
public FTPWindowService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
iservice.Start();
}
protected override void OnStop()
{
iservice.Stop();
}
}
Hope this helps
Best Regards,
Niladri Biswas
Vishalbedre, if this helps please login to Mark As Answer. | Alert Moderator