Dev2.PathOperations.Dev2ActivityIOBroker.EnsureFilesDontExists C# (CSharp) Method

EnsureFilesDontExists() static private method

static private EnsureFilesDontExists ( IActivityIOOperationsEndPoint src, IActivityIOOperationsEndPoint dst ) : void
src IActivityIOOperationsEndPoint
dst IActivityIOOperationsEndPoint
return void
        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);
                }
            }
        }