If these are two servers on the same local network and you have the appropriate access rights, you can probably get using the File.Copy method and transfer any path that you usually use to access the network resource in Windows Explorer (this is probably UNC path, e.g. \\TheRemoteServer\SharedFolder\MyFiles ). If you can copy the file in Explorer, the File.Copy method will be more than likely.
However, if you need to authenticate because another user on the remote server has the appropriate permissions to copy files, everything becomes a little more complicated because there is no simple .NET API for this. You can take a look at this answer to another question . Essentially, he p / calls to log on to the remote machine as another user. Once you are logged in, you can normally copy the file.
Also see this question: Accessing a shared file (UNC) from a remote, untrusted domain with credentials is a brief answer that involves using WNetUseConnection to connect to a UNC path on a remote computer with authentication.
Finally, just as a precaution, I feel that I should note that whenever you start making copies of network files, you need to be very careful to check the availability of the network path before you just blindly start copying (remote server may be unavailable, the local machine could lose network connectivity, etc.). You may also need to consider cases when the network runs out of time.
source share