How to read the FTP server data using the Windows Service?

Posted by Vishalbedre under .NET Certifications on 9/2/2011 | Points: 10 | Views : 2174 | Status : [Member] | Replies : 1
Hi,
Is anyone know, How to read the FTP server data using the Windows Service?

Thank you,
Vishal




Responses

Posted by: Niladri.biswas on: 9/7/2011 [Member] Platinum | Points: 25

Up
0
Down
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

Login to post response