A directory replication method used to copy all the contents of a directory to another directory. Just create and copy all files in the current folder with a recursive backtracking method.
Private void DirectoryCopy (String SourceDirectory) {if (! Directory.exists (SourceDirectory) ||! Directory.exists (targetdirectory) {Return;}
DirectoryInfo SourceInfo = New DirectoryInfo (SOURCEDIRECTORY); fileInfo [] fileInfo = sourceInfo.getfiles ();
Foreach (fileInfo fitemp in fileinfo) {file.copy (SOURCEDIRECTORY "//" fitemp.name, TargetDirectory "//" fitemp.name, true);}
DirectoryInfo [] diinfo = sourceInfo.getdirectories ();
foreach (DirectoryInfo diTemp in diInfo) {string sourcePath = diTemp.FullName; string targetPath = diTemp.FullName.Replace (sourceDirectory, targetDirectory); Directory.CreateDirectory (targetPath); directoryCopy (sourcePath, targetPath);}}