void RecursiveCopy(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args)
{
try
{
// List directory contents
var srcContentsFolders = src.ListFoldersInDirectory(src.IOPath);
Task.WaitAll(srcContentsFolders.Select(sourcePath => Task.Run(() =>
{
var sourceEndPoint =
ActivityIOFactory.CreateOperationEndPointFromIOPath(sourcePath);
IList<string> dirParts =
sourceEndPoint.IOPath.Path.Split(sourceEndPoint.PathSeperator().ToCharArray(),
StringSplitOptions.RemoveEmptyEntries);
var destinationPath =
ActivityIOFactory.CreatePathFromString(dst.Combine(dirParts.Last()), dst.IOPath.Username,
dst.IOPath.Password, true, dst.IOPath.PrivateKeyFile);
var destinationEndPoint =
ActivityIOFactory.CreateOperationEndPointFromIOPath(destinationPath);
dst.CreateDirectory(destinationPath, args);
TransferDirectoryContents(sourceEndPoint, destinationEndPoint, args);
})).ToArray());
}
catch(AggregateException e)
{
var message = e.InnerExceptions.Where(exception => exception != null && !string.IsNullOrEmpty(exception.Message)).Aggregate("", (current, exception) => current + exception.Message + "\r\n");
throw new Exception(message, e);
}
}