private void Backup()
{
string dbFileName = "gongqin.mdb";
string CurrentDatabasePath = Path.Combine(Environment.CurrentDirectory , dbFileName);
string backTimeStamp = Path.GetFileNameWithoutExtension(dbFileName) + "_" + DateTime.Now.Year.ToString("yyyy-MM-dd") + Path.GetExtension(dbFileName);
string destFileName = backTimeStamp + dbFileName;
FolderBrowserDialog fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
{
string PathtobackUp = fbd.SelectedPath.ToString();
destFileName = Path.Combine(PathtobackUp, destFileName);
File.Copy(CurrentDatabasePath,destFileName, true);
MessageBox.Show("successful Backup! ");
}
}
private void Restore()
{
string dbFileName = "gongqin.mdb";
string pathBackup = @"C:\SomeFolder\Backup\gongqin_20120906.mdb";
string CurrentDatabasePath = Path.Combine(Environment.CurrentDirectory, dbFileName);
File.Copy(pathBackup, CurrentDatabasePath, true);
MessageBox.Show("successful Restore! ");
}