Example #1
0
        public IndexerHelper(FtpInfo info, string pathOnServer)
        {
            _client       = SftpHelper.GetSFTPClient(info);
            _pathOnServer = info.FtpPath + pathOnServer;

            //SftpHelper.EnsurePath(_client, _pathOnServer);

            if (!_pathOnServer.EndsWith("/"))
            {
                _pathOnServer += "/";
            }
        }
Example #2
0
        public static TElSimpleSFTPClient GetSFTPClient(FtpInfo info)
        {
            TElSimpleSFTPClient client = new TElSimpleSFTPClient();

            client.Address = info.FtpAddress.Replace("ftp://", "");
            client.Port    = 22;

            client.Username = info.FtpUserName;
            client.Password = info.FtpPassword;

            client.OnKeyValidate += new TSSHKeyValidateEvent(client_OnKeyValidate);

            try
            {
                client.Open();
                return(client);
            }
            catch (Exception e)
            {
                System.Console.WriteLine("Connection failed due to exception: " + e.Message);
                System.Console.WriteLine("If you have ensured that all connection parameters are correct and you still can't connect,");
                System.Console.WriteLine("please contact EldoS support as described on http://www.eldos.com/sbb/support-tech.php");
                System.Console.WriteLine("Remember to provide details about the error that happened.");
                if (client.ServerSoftwareName.Length > 0)
                {
                    System.Console.WriteLine("Server software identified itself as: " + client.ServerSoftwareName);
                }
                try
                {
                    client.Close(true);
                    return(null);
                }
                catch
                {
                }
            }


            return(client);
        }