Created
September 17, 2012 08:17
-
-
Save fresky/3736144 to your computer and use it in GitHub Desktop.
Copy directory in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Now Create all of the directories | |
foreach (string dirPath in Directory.GetDirectories(SourcePath, "*", | |
SearchOption.AllDirectories)) | |
Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath)); | |
//Copy all the files | |
foreach (string newPath in Directory.GetFiles(SourcePath, "*.*", | |
SearchOption.AllDirectories)) | |
File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment