private void bwRestore_DoWork(object sender, DoWorkEventArgs e) { bwRestore.ReportProgress(0, "Extracting files..."); ExtractZipFile(txtBackupFile.Text, _tempPath); string jsonConfig = File.ReadAllText(Path.Combine(_tempPath, "provisioner.settings")); ProvisionerSettings settings = ProvisionerSettings.ReadFromJson(jsonConfig); IProvisionerRestore provisioner = ProvisionRestoreResolver.GetRestoreProvisioner(settings); provisioner.SetProjectFolder(txtProjectFolder.Text); provisioner.SetSettings(settings); provisioner.SetSourceFolder(_tempPath); bwRestore.ReportProgress(60, "Importing VM..."); VirtualBox box = new VirtualBox(_vBoxManagePath, _tempPath); box.ImportBox(); bwRestore.ReportProgress(90, "Copying data..."); DirectoryExtension.CopyRecursive(Path.Combine(_tempPath, "files"), txtProjectFolder.Text); provisioner.Restore(box.ImportedUUID); bwRestore.ReportProgress(100, "Done."); }
public void SaveBackupToFile(string projectPath, string tempPath) { _fastZipEvents = new FastZipEvents(); _fastZipEvents.Progress = new ProgressHandler(ProcessProgressChange); backupProgressChanged.Invoke(BackupState.CopyingFiles, 0); foreach (string path in _foldersToAdd) { string relativePath = path.Replace(projectPath + "\\", ""); string destinationPath = Path.Combine(tempPath, "files", relativePath); if (!Directory.Exists(destinationPath)) { Directory.CreateDirectory(destinationPath); } DirectoryExtension.CopyRecursive(path, destinationPath); } foreach (string path in _filesToAdd) { File.Copy(path, Path.Combine(tempPath, "files", Path.GetFileName(path)), true); } FastZip fz = new FastZip(_fastZipEvents); fz.CreateZip(_backupPath, tempPath, true, ""); }