public BackupSource(string sourcePath, SingleAssemblyResourceManager resourceManager, KlerksSoft.EasyProgressDialog.ProgressDialog progressDialog) { string expandedSourcePath = Path.GetFullPath(sourcePath); if (!Directory.Exists(expandedSourcePath)) throw new ArgumentException("Path to back up must exist!", "sourcePath"); _sourcePath = expandedSourcePath; _generalResourceManager = resourceManager; _progressDialog = progressDialog; }
public RestoreManager(string sourceBackupPath, string destinationPath, string password, SingleAssemblyResourceManager generalResourceManager, KlerksSoft.EasyProgressDialog.ProgressDialog progressDialog) { if (string.IsNullOrEmpty(password)) throw new ArgumentException("password must not be empty", "password"); _selectedBackupSourcePath = sourceBackupPath; _backupLocation = destinationPath; _password = password; _progressDialog = progressDialog; _generalResourceManager = generalResourceManager; }
public BackupManager(BackupSource source, string destinationPath, string password, string passwordCheckPhrase, SingleAssemblyResourceManager generalResourceManager, BackupCleaningOptions cleaningOptions, bool useDatabase, KlerksSoft.EasyProgressDialog.ProgressDialog progressDialog) { if (!useDatabase && !string.IsNullOrEmpty(password)) throw new ArgumentException("password must be empty if database is not used.", "password"); _source = source; _backupLocation = destinationPath; _password = password; _passwordCheckPhrase = passwordCheckPhrase; _progressDialog = progressDialog; _generalResourceManager = generalResourceManager; _cleaningOptions = cleaningOptions; _useDatabase = useDatabase; }
public static void RecursivelyCopyFolders(DirectoryInfo FromFolder, DirectoryInfo ToFolder, KlerksSoft.EasyProgressDialog.ProgressDialog progressDialog) { //Simple recursive copy. // - Does not delete additional files from destination // - Does not copy files that already exist with similar modified date (within 5 secs) foreach (FileInfo sourceFile in FromFolder.GetFiles()) { bool skipFile = false; if (File.Exists(Path.Combine(ToFolder.FullName, sourceFile.Name))) { FileInfo targetFile = new FileInfo(Path.Combine(ToFolder.FullName, sourceFile.Name)); if (targetFile.LastWriteTime.AddSeconds(5) > sourceFile.LastWriteTime && targetFile.LastWriteTime.AddSeconds(-5) < sourceFile.LastWriteTime && targetFile.Length == sourceFile.Length ) { skipFile = true; } } progressDialog.Worker_SetSpecificProgress(null, progressDialog.CurrentCount + sourceFile.Length, null); if (!skipFile) { sourceFile.CopyTo(Path.Combine(ToFolder.FullName, sourceFile.Name), true); } } foreach (DirectoryInfo sourceFolder in FromFolder.GetDirectories()) { DirectoryInfo targetFolder; if (Directory.Exists(Path.Combine(ToFolder.FullName, sourceFolder.Name))) targetFolder = new DirectoryInfo(Path.Combine(ToFolder.FullName, sourceFolder.Name)); else targetFolder = Directory.CreateDirectory(Path.Combine(ToFolder.FullName, sourceFolder.Name)); RecursivelyCopyFolders(sourceFolder, targetFolder, progressDialog); } }
public static long? GetFolderSizeRecursive(DirectoryInfo startDirectory, KlerksSoft.EasyProgressDialog.ProgressDialog progressDialog) { if (progressDialog != null && !progressDialog.Worker_IncrementProgress()) return null; long? fileSizes = 0; foreach (FileInfo nextFile in startDirectory.GetFiles()) fileSizes += nextFile.Length; foreach (DirectoryInfo nextDirectory in startDirectory.GetDirectories()) fileSizes += GetFolderSizeRecursive(nextDirectory, progressDialog); return fileSizes; }