Dev2.PathOperations.Dev2ActivityIOPathUtils.ExtractFullDirectoryPath C# (CSharp) Method

ExtractFullDirectoryPath() public static method

Extract the full directory portion of a URI
public static ExtractFullDirectoryPath ( string path ) : string
path string
return string
        public static string ExtractFullDirectoryPath(string path)
        {
            string result = path;
            StringBuilder tmpBuilder = new StringBuilder();

            if(!IsDirectory(path))
            {
                char spliter = '/';

                string[] tmp = path.Split(spliter);


                if(tmp.Length == 1)
                {
                    spliter = '\\';
                    tmp = path.Split(spliter);
                }

                for(int i = 0; i < (tmp.Length - 1); i++)
                {
                    tmpBuilder.Append(tmp[i] + spliter);
                }

                result = tmpBuilder.ToString();
            }

            return result;
        }

Usage Example

示例#1
0
        protected bool TransferDirectoryContents(IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst, IDev2CRUDOperationTO args)
        {
            if (!args.Overwrite)
            {
                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);
            }
            // TODO: cleanup this code so that result is easier to follow
            foreach (var p in srcContents)
            {
                result = PerformTransfer(src, dst, args, origDstPath, p, result);
            }
            Dev2Logger.Debug($"Transfered: {src.IOPath.Path}", GlobalConstants.WarewolfDebug);
            return(result);
        }
All Usage Examples Of Dev2.PathOperations.Dev2ActivityIOPathUtils::ExtractFullDirectoryPath