Exemple #1
0
        private void BackupButton_Click(object sender, EventArgs e)
        {
            if (GameSelect.SelectedIndex == -1)
            {
                MessageBox.Show("You must select a game");
                return;
            }

            using (IDbConnection con = Modules.DBConnection())
            {
                con.Open();
                if (con.Query <string>("SELECT Game FROM SAVES WHERE Name = '" + BackupNameField.Text + "' AND Game = '" + GameSelect.Text + "'").ToList <string>().Count > 0)
                {
                    MessageBox.Show("A backup with this name already exists, please enter another name.");
                    con.Close();
                    return;
                }

                SaveObj newSave = new SaveObj();
                newSave.Game = GameSelect.Text;
                newSave.Name = BackupNameField.Text;
                newSave.Path = "~/backups/" + GameSelect.Text + '/' + BackupNameField.Text + '/';

                con.Insert <SaveObj>(newSave);
                string path = con.Query <string>("SELECT Path FROM GAMES WHERE Name = '" + GameSelect.Text + "'").First <string>();
                con.Close();

                Directory.CreateDirectory(newSave.Path);
                DirectoryCopyExample.DirectoryCopy(path, newSave.Path, true);
                SaveSelect.Items.Add(BackupNameField.Text);
            }

            MessageBox.Show("Success!");
        }
Exemple #2
0
        private void RestoreButton_Click(object sender, EventArgs e)
        {
            string path;

            if (GameSelect.Text == "Select Game")
            {
                MessageBox.Show("You must select a game");
                return;
            }

            if (SaveSelect.Text == null)
            {
                MessageBox.Show("Select a backup to restore.");
                return;
            }

            using (IDbConnection con = Modules.DBConnection())
            {
                con.Open();
                path = con.Query <string>("SELECT Path FROM GAMES WHERE Name = '" + GameSelect.Text + "'").First <string>();
                con.Close();
            }

            DirectoryCopyExample.DirectoryCopy("~/backups/" + GameSelect.Text + '/' + SaveSelect.Text + '/', path, true);
            MessageBox.Show("Success!");
        }