public string ArchiveFilename(BackupDirectory targetDir, bool timestamped)
 {
     if (timestamped)
         return String.Format("{0}.{1}.zip", Path.Combine(targetDir.FullPath, this.Name), DateTime.Now.ToString("yyyyMMdd-HHmm"));
     else
         return String.Format("{0}.zip", Path.Combine(targetDir.FullPath, this.Name));
 }
        private void LocateBackupDirectory(object sender, RoutedEventArgs e)
        {
            var folderBrowserDlg = new System.Windows.Forms.FolderBrowserDialog();

            MessageBox.Show("Please select the folder to store backups in.");
            folderBrowserDlg.ShowNewFolderButton = true;
            if (Properties.Settings.Default.BackupFolder != "")
            {
                folderBrowserDlg.SelectedPath = Properties.Settings.Default.BackupFolder;
            }
            else
            {
                folderBrowserDlg.SelectedPath = Directory.GetCurrentDirectory();
            }
            System.Windows.Forms.DialogResult res = folderBrowserDlg.ShowDialog();
            if (res == System.Windows.Forms.DialogResult.OK)
            {
                MessageBox.Show("New backups will be saved and loaded from:\n" + folderBrowserDlg.SelectedPath);

                Properties.Settings.Default.BackupFolder = folderBrowserDlg.SelectedPath;
                Properties.Settings.Default.Save();

                this.backupDir = new BackupDirectory(Properties.Settings.Default.BackupFolder);
                this.PopulateBackups(sender, e);
            }
        }
Exemple #3
0
 public string ArchiveFilename(BackupDirectory targetDir, bool timestamped)
 {
     if (timestamped)
     {
         return(String.Format("{0}.{1}.zip", Path.Combine(targetDir.FullPath, this.Name), DateTime.Now.ToString("yyyyMMdd-HHmm")));
     }
     else
     {
         return(String.Format("{0}.zip", Path.Combine(targetDir.FullPath, this.Name)));
     }
 }
        public void Archive(BackupDirectory targetDir, bool deleteAfter = false, bool timestampArchive = true)
        {
            if (new FileInfo(this.ArchiveFilename(targetDir, timestampArchive)).Exists)
                throw new InvalidOperationException("Destination filename exists.");

            using (var zip = new ZipFile())
            {
                zip.CompressionLevel = CompressionLevel.None;
                zip.AddDirectory(this.FullPath);
                zip.Save(this.ArchiveFilename(targetDir, timestampArchive));
            }

            if (deleteAfter)
                this.Delete();
        }
Exemple #5
0
        public void Archive(BackupDirectory targetDir, bool deleteAfter = false, bool timestampArchive = true)
        {
            if (new FileInfo(this.ArchiveFilename(targetDir, timestampArchive)).Exists)
            {
                throw new InvalidOperationException("Destination filename exists.");
            }

            using (var zip = new ZipFile())
            {
                zip.CompressionLevel = CompressionLevel.None;
                zip.AddDirectory(this.FullPath);
                zip.Save(this.ArchiveFilename(targetDir, timestampArchive));
            }

            if (deleteAfter)
            {
                this.Delete();
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (Properties.Settings.Default.PathToDFExe == "" || !File.Exists(Properties.Settings.Default.PathToDFExe))
            {
                this.LocateDF2010(sender, e);
            }

            if (Properties.Settings.Default.BackupFolder == "" || !Directory.Exists(Properties.Settings.Default.BackupFolder))
            {
                this.LocateBackupDirectory(sender, e);
            }

            FileInfo fi          = new FileInfo(Properties.Settings.Default.PathToDFExe);
            string   saveDirPath = System.IO.Path.Combine(fi.DirectoryName, "data", "save");

            this.saveDirectory = new SaveDirectory(saveDirPath);
            this.backupDir     = new BackupDirectory(Properties.Settings.Default.BackupFolder);

            this.PopulateSaveGames(sender, e);
            this.PopulateBackups(sender, e);
        }