本帖最后由 dingxinghui 于 2010-07-26 21:19:06 编辑

解决方案 »

  1.   

    http://topic.csdn.net/u/20081027/23/1121933a-8fd1-490c-bec2-8cf3e3a3176d.html
      

  2.   

    访问远程的ftp应该需要身份验证的。可以用“映射网络驱动器”实现,不知道是不是想要的结果。
      

  3.   


    private string[] GetFileList(string path, string WRMethods)//上面的代码示例了如何从ftp服务器上获得文件列表
      {
      string[] downloadFiles;
      StringBuilder result = new StringBuilder();
      try
      {
      Connect(path);
      reqFTP.Method = WRMethods;
      WebResponse response = reqFTP.GetResponse();
      StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);//中文文件名
      string line = reader.ReadLine();
      while (line != null)
      {
      result.Append(line);
      result.Append("\n");
      line = reader.ReadLine();
      }
      // to remove the trailing '\n'  
      result.Remove(result.ToString().LastIndexOf('\n'), 1);
      reader.Close();
      response.Close();
      return result.ToString().Split('\n');
      }
      catch (Exception ex)
      {
      System.Windows.Forms.MessageBox.Show(ex.Message);
      downloadFiles = null;
      return downloadFiles;
      }
      }
      public string[] GetFileList(string path)//上面的代码示例了如何从ftp服务器上获得文件列表
      {
      return GetFileList("ftp://" + ftpServerIP + "/" + path, WebRequestMethods.Ftp.ListDirectory);
      }
      public string[] GetFileList()//上面的代码示例了如何从ftp服务器上获得文件列表
      {
      return GetFileList("ftp://" + ftpServerIP + "/", WebRequestMethods.Ftp.ListDirectory);
      }