Example #1
0
        /// <summary>
        /// Copies the specified source directory's contents to the specified destination directory.
        /// If the destination directory does not exist, it will be created first. If the source
        /// directory contains sub directories, those and their content will also be copied. If the
        /// copy fails at any point in the process, the user is notified of the problem and
        /// an attempt is made to remove the destination directory if the failure happened part
        /// way through the process.
        /// </summary>
        /// <param name="sourcePath">Directory whose contents will be copied</param>
        /// <param name="destinationPath">Destination directory receiving the content of the source directory</param>
        /// <returns>true if successful, otherwise, false.</returns>
        public static bool CopyDirectoryContents(string sourcePath, string destinationPath)
        {
            try
            {
                DirectoryHelper.Copy(sourcePath, destinationPath);
            }
            catch (Exception e)
            {
                //Review: generally, it's better if Palaso doesn't undertake to make these kind of UI decisions.
                //I've extracted CopyDirectoryWithException, so as not to mess up whatever client is using this version
                ReportFailedCopyAndCleanUp(e, sourcePath, destinationPath);
                return(false);
            }

            return(true);
        }
Example #2
0
 public static void CopyDirectoryWithException(string sourcePath, string destinationPath, bool overwrite = false)
 {
     DirectoryHelper.Copy(sourcePath, destinationPath, overwrite);
 }