RIG
متخصص C#.net
کد:
[SIZE=2][COLOR=#0000ff]
using[/COLOR][/SIZE][SIZE=2] System;
[/SIZE][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Collections.Generic;
[/SIZE][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.ComponentModel;
[/SIZE][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Data;
[/SIZE][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Drawing;
[/SIZE][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Linq;
[/SIZE][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Text;
[/SIZE][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Windows.Forms;
[/SIZE][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.Data.OleDb;
[/SIZE][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][SIZE=2] System.IO;
[/SIZE][SIZE=2][COLOR=#0000ff]namespace[/COLOR][/SIZE][SIZE=2] abk
{
[/SIZE][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]partial[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#2b91af]Form1[/COLOR][/SIZE][SIZE=2] : [/SIZE][SIZE=2][COLOR=#2b91af]Form
[/COLOR][/SIZE][SIZE=2]{
[/SIZE][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2] Form1()
{
InitializeComponent();
}
[/SIZE][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=2] button1_Click([/SIZE][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][SIZE=2] sender, [/SIZE][SIZE=2][COLOR=#2b91af]EventArgs[/COLOR][/SIZE][SIZE=2] e)
{
[/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] CurrentDatabasePath = [/SIZE][SIZE=2][COLOR=#2b91af]Environment[/COLOR][/SIZE][SIZE=2].CurrentDirectory + [/SIZE][SIZE=2][COLOR=#a31515]@"\db.mdb"[/COLOR][/SIZE][SIZE=2];
[/SIZE][SIZE=2][COLOR=#2b91af]FolderBrowserDialog[/COLOR][/SIZE][SIZE=2] fbd = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#2b91af]FolderBrowserDialog[/COLOR][/SIZE][SIZE=2]();
[/SIZE][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] (fbd.ShowDialog() == [/SIZE][SIZE=2][COLOR=#2b91af]DialogResult[/COLOR][/SIZE][SIZE=2].OK)
{
[/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] PathtobackUp = fbd.SelectedPath.ToString();
[/SIZE][SIZE=2][COLOR=#2b91af]File[/COLOR][/SIZE][SIZE=2].Copy(CurrentDatabasePath, PathtobackUp + [/SIZE][SIZE=2][COLOR=#a31515]@"\BackUp.bk"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][SIZE=2]);
progressBar1.PerformStep();
[/SIZE][SIZE=2][COLOR=#2b91af]MessageBox[/COLOR][/SIZE][SIZE=2].Show([/SIZE][SIZE=2][COLOR=#a31515]"پشتیبان گیری با موفقیت انجام شد"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515]"ایجاد پشتیبان"[/COLOR][/SIZE][SIZE=2]);
progressBar1.Value = 0;
}
}
[/SIZE][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=2] button2_Click([/SIZE][SIZE=2][COLOR=#0000ff]object[/COLOR][/SIZE][SIZE=2] sender, [/SIZE][SIZE=2][COLOR=#2b91af]EventArgs[/COLOR][/SIZE][SIZE=2] e)
{
[/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] PathToRestoreDB = [/SIZE][SIZE=2][COLOR=#2b91af]Environment[/COLOR][/SIZE][SIZE=2].CurrentDirectory + [/SIZE][SIZE=2][COLOR=#a31515]@"\db.mdb"[/COLOR][/SIZE][SIZE=2];
[/SIZE][SIZE=2][COLOR=#2b91af]OpenFileDialog[/COLOR][/SIZE][SIZE=2] ofd = [/SIZE][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#2b91af]OpenFileDialog[/COLOR][/SIZE][SIZE=2]();
ofd.Filter = [/SIZE][SIZE=2][COLOR=#a31515]"Text file (*.bk)|*.bk"[/COLOR][/SIZE][SIZE=2];
[/SIZE][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][SIZE=2] (ofd.ShowDialog() == [/SIZE][SIZE=2][COLOR=#2b91af]DialogResult[/COLOR][/SIZE][SIZE=2].OK)
{
[/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] Filetorestore = ofd.FileName;
[/SIZE][SIZE=2][COLOR=#2b91af]File[/COLOR][/SIZE][SIZE=2].Copy(Filetorestore, PathToRestoreDB,[/SIZE][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][SIZE=2]);
progressBar1.PerformStep();
[/SIZE][SIZE=2][COLOR=#2b91af]MessageBox[/COLOR][/SIZE][SIZE=2].Show([/SIZE][SIZE=2][COLOR=#a31515]"پشتیبان با موفقیت بازگردانی شد"[/COLOR][/SIZE][SIZE=2],[/SIZE][SIZE=2][COLOR=#a31515]"بازگرداندن پشتیبان"[/COLOR][/SIZE][SIZE=2]);
progressBar1.PerformStep();
progressBar1.Value = 0;
}
}
}
}
[/SIZE]