I am trying to copy a folder from a source to a destination. The source and destination folder will be in the same directory. The structure of the folder will vary each copy, so it needs to be generic. The folder will contain files, and subdirectories that need to be copied over. So all in all the entire contents of one folder should be copied no matter what it contains to another folder.
I hope this isnt too vauge. But just a quick example of what i'm looking for: Source folder path: c:\directories\versions\11.0.2 Destination folder path: c:\directories\versions\11.0.3
copy all of 11.0.2 contents into 11.0.3
Here is the code I currently have that isn't effective:
//Create all of the directories
foreach (string dirPath in Directory.GetDirectories(sourceDir, "*",
SearchOption.AllDirectories))
Directory.CreateDirectory(dirPath.Replace(sourceDir, targetDir));
//Copy all the files
foreach (string newPath in Directory.GetFiles(sourceDir, "*.*",
SearchOption.AllDirectories))
File.Copy(newPath, newPath.Replace(sourceDir, targetDir));
Any ideas of how to accomplish this?