当前位置: 首页>>代码示例>>C#>>正文


C# IActivityIOOperationsEndPoint.ListFoldersInDirectory方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:28,代码来源:Dev2ActivityIOBroker.cs

示例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);
                    }
                }
            }
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:59,代码来源:Dev2ActivityIOBroker.cs

示例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);
 }
开发者ID:Robin--,项目名称:Warewolf,代码行数:8,代码来源:Dev2ActivityIOBroker.cs


注:本文中的IActivityIOOperationsEndPoint.ListFoldersInDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。