本文整理汇总了C#中IActivityIOOperationsEndPoint.ListFilesInDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# IActivityIOOperationsEndPoint.ListFilesInDirectory方法的具体用法?C# IActivityIOOperationsEndPoint.ListFilesInDirectory怎么用?C# IActivityIOOperationsEndPoint.ListFilesInDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IActivityIOOperationsEndPoint
的用法示例。
在下文中一共展示了IActivityIOOperationsEndPoint.ListFilesInDirectory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransferDirectoryContents
/// <summary>
/// Transfer the contents of the directory
/// </summary>
/// <param name="src"></param>
/// <param name="dst"></param>
/// <param name="args"></param>
bool TransferDirectoryContents(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst,
Dev2CRUDOperationTO args)
{
ValidateSourceAndDestinationContents(src, dst, args);
if(args.DoRecursiveCopy)
{
RecursiveCopy(src, dst, args);
}
var srcContents = src.ListFilesInDirectory(src.IOPath);
var result = true;
var origDstPath = Dev2ActivityIOPathUtils.ExtractFullDirectoryPath(dst.IOPath.Path);
if(!dst.PathExist(dst.IOPath))
{
CreateDirectory(dst, args);
}
// get each file, then put it to the correct location
// ReSharper disable once LoopCanBeConvertedToQuery
foreach(var p in srcContents)
{
result = PerformTransfer(src, dst, args, origDstPath, p, result);
}
Dev2Logger.Log.Debug(string.Format("Transfered: {0}", src.IOPath.Path));
return result;
}
示例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);
}