Example #1
0
        private void createBackup()
        {
            string   tempFile   = Path.GetTempFileName();
            Database database   = Database.CreateDatabase(tempFile);
            Settings settings   = new Settings(database);
            string   backupName = "Unnamed Backup";

            for (int i = 2; this.backups.Contains(backupName); i++)
            {
                backupName = String.Format("Unnamed Backup {0}", i);
            }
            settings.PopulateInitial(backupName);

            PropertiesForm propertiesForm = new PropertiesForm(settings, this.backups);

            propertiesForm.ShowDialog();

            if (propertiesForm.Saved == false)
            {
                database.Close();
                return;
            }

            propertiesForm.Close();

            string destFile = Path.Combine(this.backupsPath, settings.Name + Constants.BACKUP_EXTENSION);

            database.Close();

            try {
                if (!Directory.Exists(this.backupsPath))
                {
                    Directory.CreateDirectory(this.backupsPath);
                }
                File.Move(tempFile, destFile);
            }
            catch (IOException e) { this.showError(e.Message); }
            this.populateBackupsList();
        }