Copy() public static method

Copies the contents of one folder, to another.
public static Copy ( string sourceDirName, string destDirName, bool copySubDirs = true, bool overwriteFiles = false ) : void
sourceDirName string The source folder, being copied
destDirName string The destination dicrectoy, where all the copies will be stored. /// The directory does NOT have to exist.
copySubDirs bool Recursively copy sub folders?
overwriteFiles bool
return void
Example #1
0
        /// <summary>
        /// Restores the ranked python files back to the original state, without affecting
        /// any custom scripts or medal data files
        /// </summary>
        public static void RestoreRankedPyFiles()
        {
            // Use my handy extension method to Copy over the files
            string path = (Installed) ? BF2Server.PythonPath : StatsBackupPath;

            DirectoryExt.Copy(Paths.RankedPythonPath, path, true, true);
        }
Example #2
0
        /// <summary>
        /// Backsup the current python files, and installs the ranked enabled ones
        /// </summary>
        public static void BackupAndInstall()
        {
            if (Installed)
            {
                return;
            }

            // Make sure we arent Ambiguous. If the backup folder exists, just leave it!!!
            // If we have both backup folders, start fresh install
            if (Directory.Exists(BackupPath) && Directory.Exists(StatsBackupPath))
            {
                Directory.Delete(StatsBackupPath, true);
                Directory.Delete(BF2Server.PythonPath, true);
            }
            else
            {
                // move the current "normal" files over to the backup path
                Directory.Move(BF2Server.PythonPath, BackupPath);
            }

            // Make sure we dont have an empty backup folder
            if (!Directory.Exists(StatsBackupPath))
            {
                DirectoryExt.Copy(Paths.RankedPythonPath, BF2Server.PythonPath, true);
            }
            else
            {
                Directory.Move(StatsBackupPath, BF2Server.PythonPath);
            }

            // Sleep
            System.Threading.Thread.Sleep(500);
        }
Example #3
0
        /// <summary>
        /// Removes the rank enabled python files, and installs the originals back
        /// </summary>
        public static void RemoveAndRestore()
        {
            if (!Installed)
            {
                return;
            }

            // Make sure we dont have a pending error here
            if (Directory.Exists(StatsBackupPath))
            {
                Directory.Delete(StatsBackupPath, true);
            }

            // Backup the users new bf2s python files
            Directory.Move(BF2Server.PythonPath, StatsBackupPath);

            // Make sure we have a backup folder!!
            if (!Directory.Exists(BackupPath))
            {
                // Copy over the default python files
                DirectoryExt.Copy(Paths.DefaultPythonPath, BF2Server.PythonPath, true);
            }
            else
            {
                // Copy back the original contents
                Directory.Move(BackupPath, BF2Server.PythonPath);
            }

            // Stop for a breather
            System.Threading.Thread.Sleep(500);
        }