Create FTP tool

I think This is how ftpwebRequest class work internally.

you can refer RFC FTP google it.

protected void Page_Load(object sender, EventArgs e)
{
try
{
string user = "";
string pwd = "";

System.Net.Sockets.TcpClient tcpclient = new System.Net.Sockets.TcpClient();
tcpclient.Connect("IP_ADDRESS", INT_PORT_NO);
NetworkStream ns = tcpclient.GetStream();
StreamWriter writer = new StreamWriter(ns);
StreamReader reader = new StreamReader(ns);
writer.WriteLine("USER " + user );
writer.Flush();
Response.Write(reader.ReadLine()+"
");
writer.WriteLine("PASS " + pwd);
writer.Flush();


Response.Write(reader.ReadLine() +"
");

Response.Write(reader.ReadLine() + "
");




}
catch(Exception ex)
{

}
}

Monday, August 25, 2008