Пример #1
0
        public override bool FileExists(string remotePath)
        {
            if (_client.Exists(remotePath))
            {
                Renci.SshNet.Sftp.SftpFile entry = _client.Get(remotePath);
                return(!entry.IsDirectory);
            }

            return(false);
        }
Пример #2
0
 public static bool CheckFileExistsOnFTP(string fileName)
 {
     try
     {
         string logMessage  = "";
         long   ftp_fileLen = 0;
         using (var sftp = new Renci.SshNet.SftpClient(FTP_SERVER, 22, FTP_USR_ID, FTP_USR_PW))
         {
             try
             {
                 sftp.Connect();
                 SftpFile file = sftp.Get(fileName);
                 ftp_fileLen = file.Attributes.Size;
             }
             catch (Exception Sftpex)
             {
                 AuditLog.Log("Exception Line 129 " + Sftpex.ToString());
             }
         }
         long fileLen = new System.IO.FileInfo(Path.Combine(Path.GetTempPath(), fileName)).Length;
         logMessage = "BlueX File is existed to FTP? ";
         if (ftp_fileLen == fileLen)
         {
             logMessage += "[Yes]";
         }
         else
         {
             logMessage += "[No]";
         }
         AuditLog.Log(logMessage);
         return(true);
     }
     catch (WebException ex)
     {
         AuditLog.Log("Exception Line 148 " + ex.Message);
         FtpWebResponse response = (FtpWebResponse)ex.Response;
         if (response.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable)
         {
             return(false);
         }
     }
     return(false);
 }