IList<IActivityIOPath> ListDirectorySftp(IActivityIOPath src)
{
List<IActivityIOPath> result = new List<IActivityIOPath>();
var sftp = BuildSftpClient(src);
try
{
var fromPath = ExtractFileNameFromPath(src.Path);
var fileList = sftp.ListDirectory(fromPath).Select(a => a.Name);
result.AddRange(from string file in fileList
where !file.EndsWith("..") && !file.EndsWith(".")
select BuildValidPathForFtp(src, file)
into uri
select ActivityIOFactory.CreatePathFromString(uri, src.Username, src.Password, src.PrivateKeyFile));
}
catch(Exception)
{
throw new DirectoryNotFoundException(string.Format("Directory '{0}' was not found", src.Path));
}
finally
{
sftp.Dispose();
}
return result;
}