1
Answer

Copy file from Local PC to remote server share

Rajesh Gsn

Rajesh Gsn

7y
275
1
Hi 
 
I want to copy files from my local machine to remote directory using different credentials.
 
Kindly help me . 
Answers (1)
1
Nilesh Shah

Nilesh Shah

NA 22.3k 214.9k 7y
Is the remote directory accessible as a network share? can you browse it in your windows file explorer?
 
if so, and if you have credentials to connect, following is simple code to copy file using C#:
  1. using ( new Impersonator( "username""domainname""password" ) )  
  2. {  
  3.    File.Copy(sourcefile,destinationfile);  

read more on C# File.Copy on MSDN