Exemple #1
0
        public void MoveFtpProcessedFile(string filePath, string processedFilesFtpFolder, string processedFileTextToAppend)
        {
            var movedFile = processedFilesFtpFolder + filePath.Split('/').Last() + processedFileTextToAppend;
            _logger.InfoFormat("Moving file {0} to {1}", filePath, movedFile);
            var client = new FtpClient(new FtpInfo(_ftpInfo.Address, _ftpInfo.UserName, _ftpInfo.PassWord));
            client.MoveFtpProcessedFile(filePath, processedFilesFtpFolder, processedFileTextToAppend);

            //var client = new SftpClient(getHost(_ftpInfo.Address), _ftpInfo.UserName, _ftpInfo.PassWord);
            //client.Connect();
            //client.RenameFile(filePath, movedFile);
            //client.Disconnect();
        }
Exemple #2
0
        public IList<string> ReadLinesFromFtpFile(string file)
        {
            var result = new List<string>();

            var client = new FtpClient(new FtpInfo(_ftpInfo.Address, _ftpInfo.UserName, _ftpInfo.PassWord));
            result = client.ReadLinesFromFtpFile(file).ToList();

            //var client = new SftpClient(getHost(_ftpInfo.Address), _ftpInfo.UserName, _ftpInfo.PassWord);
            //client.Connect();
            //result = client.ReadAllLines(file).ToList();
            //client.Disconnect();
            return result;
        }
Exemple #3
0
        private IList<string> getAllFilePaths(string remotePath, string regExpresion)
        {
            var fileList = new List<string>();

            _logger.DebugFormat("_ftpInfo.Address: {0}", _ftpInfo.Address);
            _logger.DebugFormat(" _ftpInfo.UserName: {0}", _ftpInfo.UserName);
            _logger.DebugFormat("_ftpInfo.PassWord: {0}", _ftpInfo.PassWord);
            _logger.DebugFormat("RemotePath: {0}", remotePath);

            var client = new FtpClient(new FtpInfo(_ftpInfo.Address, _ftpInfo.UserName, _ftpInfo.PassWord));
            fileList= client.GetAllFtpFiles(remotePath, regExpresion).ToList();
                //new SftpClient(getHost(_ftpInfo.Address), 22, _ftpInfo.UserName, _ftpInfo.PassWord);
            //client.Connect();
            //fileList = client.ListDirectory(remotePath).Select(x => x.FullName).ToList();
            //client.Disconnect();
            return fileList;
        }