public static IEnumerable<SftpFile> GetList(string host, string folder, string userName, string password) { using (var sftp = new SftpClient(host, userName, password)) { sftp.ErrorOccurred += Sftp_ErrorOccurred; sftp.Connect(); var toReturn = sftp.ListDirectory(folder).ToList(); sftp.Disconnect(); return toReturn; } }