コード例 #1
0
ファイル: Backups.cs プロジェクト: treasureboy/XLToolbox
        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");
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 public BackupFilesCollection(Backups backups)
     : base(new System.Collections.ObjectModel.ObservableCollection <BackupFile>(backups.Files))
 {
 }