private void GetBackup_Click(object sender, EventArgs e) { if (!System.IO.Directory.Exists(targetPath)) { System.IO.Directory.CreateDirectory(targetPath); } if(System.IO.Directory.Exists(sourcePath)) { string[] files = System.IO.Directory.GetFiles(sourcePath); foreach (string s in files) { fileName = System.IO.Path.GetFileName(s); destFile = System.IO.Path.Combine(targetPath,fileName); System.IO.File.Copy(s,destFile,true); } MessageBox.Show("Backup process is complete!", "Taking a backup copy", MessageBoxButtons.OK); } else { Console.WriteLine("Source path does not exist!"); }
}