Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static bool CopyTo(string targetDirectory, string destinationDirectory)
- {
- bool blnSuccess = false;
- try{
- if(Directory.Exists(targetDirectory)){
- foreach (string dirPath in Directory.GetDirectories(targetDirectory, "*",
- SearchOption.AllDirectories)){
- Directory.CreateDirectory(dirPath.Replace(targetDirectory, destinationDirectory));
- }
- //Copy all the files & Replaces any files with the same name
- foreach (string newPath in Directory.GetFiles(targetDirectory, "*.*",
- SearchOption.AllDirectories)){
- File.Copy(newPath, newPath.Replace(targetDirectory, destinationDirectory), true);
- blnSuccess = true;
- }
- }
- }catch(Exception exCopyTo){
- Console.WriteLine("Error in ioLibrary: " + exCopyTo.Message);
- }
- return blnSuccess;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement