Using system;
Using system. IO;
Using system. net;
Using system. net. Security;
Using system. Security. cryptography. x509certificates;
Namespace Test
{
Class Program
{
Static void main (string [] ARGs)
{
Uri serveruri = new uri ("ftp://xxx.xxx.xxx.xxx ");
Ftpwebrequest request = (ftpwebrequest) webrequest. Create (serveruri );
Request. Credentials = new networkcredential ("username", "password ","");
Request. method = webrequestmethods. FTP. listdirectorydetails;
// The following four lines of code are used to support displaying SSL (explicit it SSL). ftpwebrequest in. net2.0 does not support
// Implicit SSL (implicit SSL ). If you do not need SSL, just comment them out.
Request. enablessl = true;
Servicepointmanager. servercertificatevalidationcallback =
Delegate (Object OBJ, x509certificate certificate, x509chain chain, sslpolicyerrors errors)
{Return true ;};
Ftpwebresponse response = (ftpwebresponse) request. getresponse ();
Stream responsestream = NULL;
Streamreader readstream = NULL;
Try
{
Responsestream = response. getresponsestream ();
Readstream = new streamreader (responsestream, system. Text. encoding. utf8 );
If (readstream! = NULL)
Console. writeline (readstream. readtoend ());
}
Finally
{
If (readstream! = NULL)
Readstream. Close ();
If (response! = NULL)
Response. Close ();
}
Console. Readline ();
}
}
}