直接访问普通的FTP可以哦。但是不能访问有SSL安全证书的FTP。
Request.EnableSsl = true;有人说加这个就可以了。但是没用的。
最后得到的line值是null。        private void button1_Click(object sender, EventArgs e)
        {
            StringBuilder builder = new StringBuilder();
            FtpWebRequest Request = null;
            FtpWebResponse Response = null;
            StreamReader FtpResponseStreat = null;            Request = (FtpWebRequest)FtpWebRequest.Create(new Uri(@"ftp://192.168.103.100"));
            Request.UseBinary = true;
            Request.EnableSsl = true;
            Request.Credentials = new NetworkCredential("huic", "girls123");
            Request.Method = WebRequestMethods.Ftp.ListDirectory;
            try
            {
                Response = (FtpWebResponse)Request.GetResponse();
            }
            catch (WebException ex)
            {
                Response = (FtpWebResponse)ex.Response;
            }
            FtpResponseStreat = new StreamReader(Response.GetResponseStream());
            string line = FtpResponseStreat.ReadLine();
            while (line != null)
            {
                builder.Append(line);
                builder.Append("\n");
                line = FtpResponseStreat.ReadLine();
            }
            builder.Remove(builder.ToString().LastIndexOf('\n'), 1);
            string[] str = builder.ToString().Split('\n');
            foreach (string st in str)
            {
                MessageBox.Show(st);
            }
        }

解决方案 »

  1.   

    hwrRequest.ClientCertificates.Add(X509Certificate.CreateFromCertFile("c:\\motor.https.pem.cer")); 
    这是我自己找到的资料。。从本地加载证书。!但是这个证书是从哪找的呢?!在那台服务器上导过来的吗?还是怎么说?
      

  2.   


    证书就是Ftp服务器用的那个证书吧,可以从服务器导出来。
      

  3.   

    首先要理解人家FTP服务器那边SSL怎么配置的。连接FTPS服务器,一般FtpRequest比较困难,因为微软的封装没有完整覆盖FTPS协议的全部内容。CodePlex上面有几个开源项目都能够连接FTPS,你可以参考,http://www.codeplex.com/site/search?query=FTP%20SSL