本文整理汇总了C#中IActivityIOOperationsEndPoint.ListDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# IActivityIOOperationsEndPoint.ListDirectory方法的具体用法?C# IActivityIOOperationsEndPoint.ListDirectory怎么用?C# IActivityIOOperationsEndPoint.ListDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IActivityIOOperationsEndPoint
的用法示例。
在下文中一共展示了IActivityIOOperationsEndPoint.ListDirectory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateEndPoint
string CreateEndPoint(IActivityIOOperationsEndPoint dst, Dev2CRUDOperationTO args, bool createToFile)
{
var result = ResultOk;
// check the the dir strucutre exist
var activityIOPath = dst.IOPath;
var dirParts = MakeDirectoryParts(activityIOPath, dst.PathSeperator());
// check from lowest path part up
var deepestIndex = -1;
var startDepth = dirParts.Count - 1;
var pos = startDepth;
while(pos >= 0 && deepestIndex == -1)
{
var tmpPath = ActivityIOFactory.CreatePathFromString(dirParts[pos], activityIOPath.Username,
activityIOPath.Password, true,activityIOPath.PrivateKeyFile);
try
{
if(dst.ListDirectory(tmpPath) != null)
{
deepestIndex = pos;
}
}
// ReSharper disable EmptyGeneralCatchClause
catch(Exception)
// ReSharper restore EmptyGeneralCatchClause
{
//Note that we doing a recursive create should the directory not exists
}
finally
{
pos--;
}
}
// now create all the directories we need ;)
pos = deepestIndex + 1;
var ok = true;
var origPath = dst.IOPath;
while(pos <= startDepth && ok)
{
var toCreate = ActivityIOFactory.CreatePathFromString(dirParts[pos], dst.IOPath.Username,
dst.IOPath.Password, true, dst.IOPath.PrivateKeyFile);
dst.IOPath = toCreate;
ok = CreateDirectory(dst, args);
pos++;
}
dst.IOPath = origPath;
// dir create failed
if(!ok)
{
result = ResultBad;
}
else if(dst.PathIs(dst.IOPath) == enPathType.File && createToFile)
{
if(!CreateFile(dst, args))
{
result = ResultBad;
}
}
return result;
}
示例2: EnsureFilesDontExists
static void EnsureFilesDontExists(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst)
{
if(dst.PathExist(dst.IOPath))
{
// destination is a file
if(dst.PathIs(dst.IOPath) == enPathType.File)
{
throw new Exception(
"A file with the same name exists on the destination and overwrite is set to false");
}
//destination is a folder
var dstContents = dst.ListDirectory(dst.IOPath);
var destinationFileNames = dstContents.Select(dstFile => GetFileNameFromEndPoint(dst, dstFile));
var sourceFile = GetFileNameFromEndPoint(src);
if(destinationFileNames.Contains(sourceFile))
{
throw new Exception(
"The following file(s) exist in the destination folder and overwrite is set to false :- " +
sourceFile);
}
}
}
示例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);
}