日期:2014-05-18  浏览次数:20762 次

请大家帮写用socket检测FTP上目录/文件是否存在的代码
我从网上找了好些FTP的代码,测试了一下,就socket的最快。其它的代码,不知为何,在第一次连接FTP时都慢,有时长达一分钟,之后还行。 用SOCKET的就没这问题。 
下面是找到的SOCKET操作FTP的源码,但是它没有检测ftp上的目录或文件是否存在的功能,而我很需要这个,能不能请大家帮写一下,谢谢。

using System;
using System.Net;
using System.IO;
using System.Text;
using System.Net.Sockets;
namespace FTP
{
  /// <summary>
  /// FTPClient 的摘要说明。
  /// </summary>
  public class FTPClient
  {
  #region 构造函数
  /// <summary>
  /// 缺省构造函数
  /// </summary>
  public FTPClient()
  {
  strRemoteHost = "";
  strRemotePath = "";
  strRemoteUser = "";
  strRemotePass = "";
  strRemotePort = 21;
  bConnected = false;
  } /// <summary>
  /// 构造函数
  /// </summary>
  /// <param name="remoteHost"></param>
  /// <param name="remotePath"></param>
  /// <param name="remoteUser"></param>
  /// <param name="remotePass"></param>
  /// <param name="remotePort"></param>
  public FTPClient(string remoteHost, string remotePath, string remoteUser, string remotePass, int remotePort)
  {
  strRemoteHost = remoteHost;
  strRemotePath = remotePath;
  strRemoteUser = remoteUser;
  strRemotePass = remotePass;
  strRemotePort = remotePort;
  Connect();
  }
  #endregion
  #region 登陆
  /// <summary>
  /// FTP服务器IP地址
  /// </summary>
  private string strRemoteHost;
  public string RemoteHost
  {
  get
  {
  return strRemoteHost;
  }
  set
  {
  strRemoteHost = value;
  }
  }
  /// <summary>
  /// FTP服务器端口
  /// </summary>
  private int strRemotePort;
  public int RemotePort
  {
  get
  {
  return strRemotePort;
  }
  set
  {
  strRemotePort = value;
  }
  }
  /// <summary>
  /// 当前服务器目录
  /// </summary>
  private string strRemotePath;
  public string RemotePath
  {
  get
  {
  return strRemotePath;
  }
  set
  {
  strRemotePath = value;
  }
  }
  /// <summary>
  /// 登录用户账号
  /// </summary>
  private string strRemoteUser;
  public string RemoteUser
  {
  set
  {
  strRemoteUser = value;
  }
  }
  /// <summary>
  /// 用户登录密码
  /// </summa