예제 #1
0
파일: FTPOperater.cs 프로젝트: aj-hc/SY
 /// <summary>  
 /// 得到文件列表  
 /// </summary>  
 /// <returns></returns>  
 public string[] GetList(string strPath)
 {
     if (ftp == null) ftp = this.getFtpClient();
     ftp.Connect();
     ftp.ChDir(strPath);
     return ftp.Dir("*");
 }
예제 #2
0
파일: FTPOperater.cs 프로젝트: aj-hc/SY
 /// <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.ChDir(ftpFolder);
         }
         ftp.Put(ftpFileName);
         return true;
     }
     catch
     {
         return false;
     }
 }
예제 #3
0
파일: FTPOperater.cs 프로젝트: aj-hc/SY
 /// <summary>  
 ///得到FTP传输对象  
 /// </summary>  
 public FTPClient getFtpClient()
 {
     FTPClient ft = new FTPClient();
     ft.RemoteHost = this.Server;
     ft.RemoteUser = this.User;
     ft.RemotePass = this.Pass;
     return ft;
 }
예제 #4
0
파일: FTPOperater.cs 프로젝트: aj-hc/SY
 /// <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.ChDir(ftpFolder);
         }
         ftp.GetNoBinary(ftpFileName, localFolder, localFileName);
         return true;
     }
     catch
     {
         try
         {
             ftp.DisConnect();
             ftp = null;
         }
         catch
         {
             ftp = null;
         }
         return false;
     }
 }
예제 #5
0
파일: FTPOperater.cs 프로젝트: aj-hc/SY
 /// <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.ChDir(ftpFolder);
         }
         strResult = ftp.Dir(strMask);
         return strResult;
     }
     catch
     {
         return null;
     }
 }
예제 #6
0
파일: FTPOperater.cs 프로젝트: aj-hc/SY
 /// <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.ChDir(ftpFolder);
         }
         strResult = ftp.GetFileInfo(ftpFileName);
         return strResult;
     }
     catch
     {
         return "";
     }
 }
예제 #7
0
파일: FTPOperater.cs 프로젝트: aj-hc/SY
 /// <summary>  
 /// 测试FTP服务器是否可登陆  
 /// </summary>  
 public bool CanConnect()
 {
     if (ftp == null) ftp = this.getFtpClient();
     try
     {
         ftp.Connect();
         ftp.DisConnect();
         return true;
     }
     catch
     {
         return false;
     }
 }