Really no magic here and just a simple add on to my previous post just in case you need something that can easily copy the contents of a given directory to another location. public static void CopyContentsTo(this DirectoryInfo source, string desinationDirectory) { if (string.IsNullOrEmpty(desin... { throw new ArgumentNullException("root... } if (!Directory.Exists(desinati... { Directory.CreateDirectory(d... } foreach (string file in Directory.GetFiles(source.F... ......
The .NET Framework does not offer support for a directory copy method OOB. Fortunately in .NET 3.5 we can decorate the DirectoryInfo method with our own CopyTo method using an extension method. See the below example… public static class DirectoryInfoExtensions { public static void CopyTo(this DirectoryInfo source, string rootDestinationDirectory, bool recursive) { if (string.IsNullOrEmpty(rootD... { throw new ArgumentNullException("dest... } if (!Directory.Exists(rootDest... ......