Exemplo n.º 1
0
        private void backupDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveDb = new SaveFileDialog();
            string         path   = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "{374DE290-123F-4565-9164-39C4925E467B}", String.Empty).ToString();
            dbGc           db     = new dbGc();

            try
            {
                saveDb.Filter           = "bak files (*.bak)|*.bak|All files (*.*)|*.*";
                saveDb.InitialDirectory = path;
                saveDb.RestoreDirectory = true;
                saveDb.DefaultExt       = "bak";
                if (saveDb.ShowDialog() == DialogResult.OK)
                {
                    db.backupDb(saveDb.FileName);
                    notification notification = new notification("Database backup completed.", notification.AlertType.success);
                    notification.ShowDialog();
                }
            }
            catch (Exception a)
            {
                notification notification = new notification("Database backup error.", notification.AlertType.error);
                notification.ShowDialog();
                return;
            }
        }