TcpClient tcp= new TcpClient();
tcp.Connect("192.168.10.1",21);
tcp.GetStream();
if(tcp.Connected.ToString()=="True")
{
NetworkStream ns=tcp.GetStream();
using(NetworkStream stream-tcp.GetStream())
{
byte[] username=System.Text.Encoding.ASCII.GetBytes(user+"\r\n")
stream.Wrtie(username,0,user.Length);
byte[] password=System.Text.Encoding.ASCII.GetBytes(pass+"\r\n")
stream.Wrtie(password,0,pass.Length);
MessageBox.Show(""+ns.Read(data,0,data.Length)+"");
}
}
I am using above code to ftp a router using tcpclient, it returns an error stating "530 please login with USER and PASS".
If you going to use the TcpClient class (like you are doing), then you will have to implement the FTP specification (https://www.ietf.org/rfc/rfc959.txt).
However, I think it would be better to find an FTP client library to use instead.