I need to copy many folders from a server to another server. The servers are in different domains. Is tcp or ftp should be used? I am having the login credentials to access the server.
Is it possible to use something like
string sourceFile = @"ServerIP\C:\Users\Public\public\test.txt";
string destinationFile = @"Localhost\C:\Users\Public\private\test.txt";
// To move a file or folder to a new location:
System.IO.File.Copy(sourceFile, destinationFile);
You can grab the idea of doing it using the code snippet below. You can use LogonUser to impersonate a local group also not only domain accounts.
To copy all the contents (files) inside the Directory/Folder, obviously you can use the
Directoryclass from insideSystem.IOnamespace to get all the files information.Code:
Reference: Impersonate with Local Account