Ejemplo n.º 1
0
        /// <summary>
        /// Copies the specified source folder to the destination.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="overwriteFolder">if set to <c>true</c> overwrites the destination folder if it exists.</param>
        /// <param name="overwriteItems">if set to <c>true</c> overwrites any existing items with the same name in the destination folder.</param>
        /// <returns>Whether the folder was copied or not.</returns>
        public static bool Copy(AFolder source, string destination, bool overwriteFolder = false, bool overwriteItems = false)
        {
            Exceptions.NotNullException<AFolder>(source, nameof(source));
            Exceptions.NotNullOrEmptyException(destination, nameof(destination));

            if (!overwriteFolder && Fenrir.FileSystem.FolderExists(destination))
                return false;

            FileCollisionOption itemCollision;
            if (overwriteItems)
                itemCollision = FileCollisionOption.ReplaceExisting;
            else
                itemCollision = FileCollisionOption.FailIfExists;
            
            return source.Copy(destination, FolderCollisionOption.ReplaceExisting, itemCollision) != null;
        }