yashu v

yashu v

  • NA
  • 98
  • 14.9k

copy the contents of one folder to other

Apr 12 2016 5:39 AM
how can i copy the contents of one folder to other, and other as create a folder like this format
 
 
AutomatedBuild_12_04_2016_14_30
string sourcePath = @"D:\StarTeam\CMP\Coding\AutomatedBuild";
string targetPath = @"D:\StarTeam\CMP\Coding\AutoBuildArtifacts\AutomatedBuildBackups";
if (!Directory.Exists(targetPath))
{
Directory.CreateDirectory(AutomatedBuild.DateNow());
}
foreach (var srcPath in Directory.GetFiles(sourcePath))
{
//Copy the file from sourcepath and place into mentioned target
path,
//Overwrite the file if same file is exist in target path
File.Copy(srcPath, srcPath.Replace(sourcePath, targetPath),
true);
}
 

Answers (9)