Hi
I am trying to copy whole directory tree from server's shared folder to my local machine, I found Best way to copy the entire contents of a directory in C# post and decide to use that but as I guess DirectoryInfo doesn't support network shares, how can I change this code to work with network shares as a source?
public static void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target) {
foreach (DirectoryInfo dir in source.GetDirectories())
CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name));
foreach (FileInfo file in source.GetFiles())
file.CopyTo(Path.Combine(target.FullName, file.Name));
}
EDIT
and the call is
CopyFilesRecursively(new DirectoryInfo ("\\192.168.0.11\Share"), new DirectoryInfo ("D:\Projects\"));
and getting error message
Could not find a part of the path 'D:\192.168.0.11\Share'.
Thanks a lot!