virtual public void FtpPoll(string fileName, int timeout, Dictionary <string, string> config) { fileName = fileName + ".asc"; bool printxml = config["printxml"] == "true"; if (printxml) { Console.WriteLine("Polling for outbound result file. Timeout set to " + timeout + "ms. File to wait for is " + fileName); } ChannelSftp channelSftp = null; Channel channel; string url = config["sftpUrl"]; string username = config["sftpUsername"]; string password = config["sftpPassword"]; string knownHostsFile = config["knownHostsFile"]; JSch jsch = new JSch(); jsch.setKnownHosts(knownHostsFile); Session session = jsch.getSession(username, url); session.setPassword(password); try { session.connect(); channel = session.openChannel("sftp"); channel.connect(); channelSftp = (ChannelSftp)channel; } catch (SftpException e) { throw new LitleOnlineException("Error occured while attempting to establish an SFTP connection", e); } //check if file exists SftpATTRS sftpATTRS = null; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); do { if (printxml) { Console.WriteLine("Elapsed time is " + stopWatch.Elapsed.TotalMilliseconds); } try { sftpATTRS = channelSftp.lstat("outbound/" + fileName); if (printxml) { Console.WriteLine("Attrs of file are: " + sftpATTRS.ToString()); } } catch (SftpException e) { if (printxml) { Console.WriteLine(e.message); } System.Threading.Thread.Sleep(30000); } } while (sftpATTRS == null && stopWatch.Elapsed.TotalMilliseconds <= timeout); }