protected static void Application_WorkbookBeforeSave( Microsoft.Office.Interop.Excel.Workbook Wb, bool SaveAsUI, ref bool Cancel) { string fn = Wb.FullName; if (System.IO.File.Exists(fn)) { Logger.Info("Application_WorkbookBeforeSave: Creating backup copy before saving the workbook"); string dir = UserSettings.UserSettings.Default.BackupDir; if (String.IsNullOrEmpty(dir)) { dir = ".backup"; } Backups b = new Backups(Wb.FullName, dir); if (!b.Create()) { OnBackupFailed(b.Exception); } } else { Logger.Info("Application_WorkbookBeforeSave: Skipping backup because file does not exist"); } }
public BackupsViewModel(Workbook workbook) { _wasEnabled = IsEnabled; string dir = UserSettings.UserSettings.Default.BackupDir; BackupDir = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(workbook.FullName), dir); _backups = new Backups(workbook.FullName, dir); if (_backups.Files != null) { BackupFiles = new BackupFilesCollection(_backups); } }
public BackupFilesCollection(Backups backups) : base(new System.Collections.ObjectModel.ObservableCollection <BackupFile>(backups.Files)) { }