本文整理汇总了C#中IActivityIOOperationsEndPoint.ListFoldersInDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# IActivityIOOperationsEndPoint.ListFoldersInDirectory方法的具体用法?C# IActivityIOOperationsEndPoint.ListFoldersInDirectory怎么用?C# IActivityIOOperationsEndPoint.ListFoldersInDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IActivityIOOperationsEndPoint
的用法示例。
在下文中一共展示了IActivityIOOperationsEndPoint.ListFoldersInDirectory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecursiveCopy
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);
}
}
示例2: ValidateSourceAndDestinationContents
/// <summary>
/// Transfer the contents of the directory
/// </summary>
/// <param name="src"></param>
/// <param name="dst"></param>
/// <param name="args"></param>
void ValidateSourceAndDestinationContents(IActivityIOOperationsEndPoint src,
IActivityIOOperationsEndPoint dst,
Dev2CRUDOperationTO args)
{
if(!args.Overwrite)
{
var srcContentsFolders = src.ListFoldersInDirectory(src.IOPath);
foreach(var sourcePath in srcContentsFolders)
{
var sourceEndPoint =
ActivityIOFactory.CreateOperationEndPointFromIOPath(sourcePath);
IList<string> dirParts =
sourceEndPoint.IOPath.Path.Split(sourceEndPoint.PathSeperator().ToCharArray(),
StringSplitOptions.RemoveEmptyEntries);
var directory = dirParts.Last();
var destinationPath =
ActivityIOFactory.CreatePathFromString(dst.Combine(directory),
dst.IOPath.Username,
dst.IOPath.Password, true, dst.IOPath.PrivateKeyFile);
var destinationEndPoint =
ActivityIOFactory.CreateOperationEndPointFromIOPath(destinationPath);
if(destinationEndPoint.PathExist(destinationEndPoint.IOPath))
{
ValidateSourceAndDestinationContents(sourceEndPoint, destinationEndPoint, args);
}
}
var srcContents = src.ListFilesInDirectory(src.IOPath);
var dstContents = dst.ListFilesInDirectory(dst.IOPath);
var sourceFileNames = srcContents.Select(srcFile => GetFileNameFromEndPoint(src, srcFile)).ToList();
var destinationFileNames = dstContents.Select(dstFile => GetFileNameFromEndPoint(dst, dstFile)).ToList();
if(destinationFileNames.Count > 0)
{
var commonFiles = sourceFileNames.Where(destinationFileNames.Contains).ToList();
if(commonFiles.Count > 0)
{
var fileNames = commonFiles.Aggregate("",
(current, commonFile) =>
current + "\r\n" + commonFile);
throw new Exception(
"The following file(s) exist in the destination folder and overwrite is set to false:- " +
fileNames);
}
}
}
}
示例3: ListDirectory
public IList<IActivityIOPath> ListDirectory(IActivityIOOperationsEndPoint src, ReadTypes readTypes)
{
if(readTypes == ReadTypes.FilesAndFolders)
{
return src.ListDirectory(src.IOPath);
}
return readTypes == ReadTypes.Files ? src.ListFilesInDirectory(src.IOPath) : src.ListFoldersInDirectory(src.IOPath);
}