/// <summary> /// Deletes the temp folder and its contents. /// This instance must have been set to use temporary files. /// </summary> public void DeleteTemp() { if (!_useTempDir) { throw new InvalidOperationException("This instance doesn't use temp directories"); } DirectoryEx.DeleteIfExists(_path + TempFolder, true); }
/// <summary> /// Restores the backup folder created by <see cref="MoveToBackup"/>. /// Existing files in the data folder are overwritten by backup files. /// </summary> public void RestoreBackup() { var backupPath = _path + BackupFolder; DirectoryEx.MoveIfExists(backupPath + AssetsFolder, _assetsPath, true); FileUtils.MoveIfExists(backupPath + SkillTreeFile, _skillTreePath, true); FileUtils.MoveIfExists(backupPath + OptsFile, _optsPath, true); DirectoryEx.DeleteIfExists(backupPath); }
/// <summary> /// Moves the existing files to a backup folder. /// </summary> public void MoveToBackup() { var backupPath = _path + BackupFolder; DirectoryEx.DeleteIfExists(backupPath, true); Directory.CreateDirectory(backupPath); DirectoryEx.MoveIfExists(_assetsPath, backupPath + AssetsFolder, true); FileUtils.MoveIfExists(_skillTreePath, backupPath + SkillTreeFile, true); FileUtils.MoveIfExists(_optsPath, backupPath + OptsFile, true); }
/// <summary> /// Moves the files from the temp folder to the data folder. /// This instance must have been set to use temporary files. /// </summary> public void MoveTemp() { if (!_useTempDir) { throw new InvalidOperationException("This instance doesn't use temp directories"); } DirectoryEx.MoveIfExists(_tempAssetsPath, _assetsPath, true); FileUtils.MoveIfExists(_tempSkillTreePath, _skillTreePath, true); FileUtils.MoveIfExists(_tempOptsPath, _optsPath, true); DirectoryEx.DeleteIfExists(_path + TempFolder); }
private static void Backup(string path, bool isFolder) { if (isFolder && Directory.Exists(path)) { var backupPath = path + "Backup"; DirectoryEx.DeleteIfExists(backupPath, true); Directory.CreateDirectory(backupPath); foreach (var filePath in Directory.GetFiles(path)) { File.Copy(filePath, filePath.Replace(path, backupPath), true); } } else if (!isFolder && File.Exists(path)) { File.Copy(path, path + ".bak", true); } }
/// <summary> /// Deletes the backup folder and its contents. /// </summary> public void DeleteBackup() { DirectoryEx.DeleteIfExists(_path + BackupFolder, true); }
public void Dispose() => DirectoryEx.DeleteIfExists(DirPath);