Backup program
private void Backupfiles (string from,string to)
{
If the original program directory exists
if (Directory.Exists (from))
{
If the destination path exists
if (Directory.Exists (to))
{
Gets all subdirectories in the specified directory
string[] subfolder = Directory.getdirectories (from);
Traverse
foreach (string folder in subfolder)
{
Backupfiles (folder, to + @ "\" + path.getfilename (folder));
}
Get all files in the specified directory
string[] files = Directory.GetFiles (from);
foreach (string file in files)
{
File.Copy (file, to + @ "\" + path.getfilename (file), true);
}
}
Else
{
Create a Directory
Directory.CreateDirectory (to);
Gets all subdirectories in the specified directory
string[] subfolder = Directory.getdirectories (from);
Traverse
foreach (string folder in subfolder)
{
Backupfiles (folder, to + @ "\" + path.getfilename (folder));
}
Get all files in the specified directory
string[] files = Directory.GetFiles (from);
foreach (string file in files)
{
File.Copy (file, to + @ "\" + path.getfilename (file), true);
}
}
}
Else
{
Logcommon.loginfor ("Applog", "program file directory does not exist");
}
}
Copying files and subdirectories under a directory