Example #1
0
        public static void Backup(string path)
        {
            var backupPath = Path.Combine(Path.GetDirectoryName(path), Path.GetFileName(path) + backupPostFix);

            if (Directory.Exists(path) == false)
            {
                return;
            }
            DirectoryUtility.Clean(path);
            DirectoryUtility.Move(path, backupPath);
            DirectoryUtility.Delete(path);
        }
Example #2
0
        public static void Copy(string path, Action action)
        {
            DirectoryUtility.Backup(path);
            DirectoryUtility.Prepare(path);

            try
            {
                action();
                DirectoryUtility.Clean(path);
            }
            catch (Exception e)
            {
                DirectoryUtility.Restore(path);
                throw e;
            }
        }