Exemple #1
0
 /// <summary>
 /// 下载文件
 /// </summary>
 /// <param name="ftpFolder">ftp目录</param>
 /// <param name="ftpFileName">ftp文件名</param>
 /// <param name="localFolder">本地目录</param>
 /// <param name="localFileName">本地文件名</param>
 public bool getFileNoBinary(string ftpFolder, string ftpFileName, string localFolder, string localFileName)
 {
     try
     {
         if (ftp == null)
         {
             ftp = this.getFtpClient();
         }
         if (!ftp.Connected)
         {
             ftp.connect();
             ftp.changeDir(ftpFolder);
         }
         ftp.getNoBinary(ftpFileName, localFolder, localFileName);
         return(true);
     }
     catch
     {
         try
         {
             ftp.disConnect();
             ftp = null;
         }
         catch
         {
             ftp = null;
         }
         return(false);
     }
 }
Exemple #2
0
        /// <summary>
        ///得到FTP传输对象
        /// </summary>
        public clsFtpClient getFtpClient()
        {
            clsFtpClient ft = new clsFtpClient();

            ft.RemoteHost = this.Server;
            ft.RemoteUser = this.User;
            ft.RemotePass = this.Pass;
            return(ft);
        }
Exemple #3
0
 /// <summary>
 /// 得到文件列表
 /// </summary>
 /// <returns></returns>
 public string[] GetList(string strPath)
 {
     if (ftp == null)
     {
         ftp = this.getFtpClient();
     }
     ftp.connect();
     ftp.changeDir(strPath);
     return(ftp.dir("*"));
 }
Exemple #4
0
 /// <summary>
 /// 测试FTP服务器是否可登陆
 /// </summary>
 public bool canConnect()
 {
     if (ftp == null)
     {
         ftp = this.getFtpClient();
     }
     try
     {
         ftp.connect();
         ftp.disConnect();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #5
0
 /// <summary>
 /// 上传文件
 /// </summary>
 /// <param name="ftpFolder">ftp目录</param>
 /// <param name="ftpFileName">ftp文件名</param>
 public bool putFile(string ftpFolder, string ftpFileName)
 {
     try
     {
         if (ftp == null)
         {
             ftp = this.getFtpClient();
         }
         if (!ftp.Connected)
         {
             ftp.connect();
             ftp.changeDir(ftpFolder);
         }
         ftp.put(ftpFileName);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #6
0
 /// <summary>
 /// 得到文件列表
 /// </summary>
 /// <param name="ftpFolder">FTP目录</param>
 /// <returns>FTP通配符号</returns>
 public string[] getFileList(string ftpFolder, string strMask)
 {
     string[] strResult;
     try
     {
         if (ftp == null)
         {
             ftp = this.getFtpClient();
         }
         if (!ftp.Connected)
         {
             ftp.connect();
             ftp.changeDir(ftpFolder);
         }
         strResult = ftp.dir(strMask);
         return(strResult);
     }
     catch
     {
         return(null);
     }
 }
Exemple #7
0
        /// <summary>
        /// 得到FTP上文件信息
        /// </summary>
        /// <param name="ftpFolder">FTP目录</param>
        /// <param name="ftpFileName">ftp文件名</param>
        public string getFileInfoConnected(string ftpFolder, string ftpFileName)
        {
            string strResult = "";

            try
            {
                if (ftp == null)
                {
                    ftp = this.getFtpClient();
                }
                if (!ftp.Connected)
                {
                    ftp.connect();
                    ftp.changeDir(ftpFolder);
                }
                strResult = ftp.getFileInfo(ftpFileName);
                return(strResult);
            }
            catch
            {
                return("");
            }
        }