Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to copy the Text file from web server to another network server using user credentials.

Eg: Server.MapPath("Test_File.txt") to "\\10.220.120.13\c:\extract"
Posted

1 solution

Hi,

Try this:
C#
string filePath = "Test_File.txt";
try
{
    WebClient client = new WebClient();
    NetworkCredential nc = new NetworkCredential(userName, password);
    File.Copy(filepath, "\\\\10.220.120.13\\Files");
    client.Credentials = nc;
    byte[] arrReturn = client.UploadFile(addy, filePath);
    Console.WriteLine(arrReturn.ToString());
}
catch (Exception ex)
{
   
}
 
Share this answer
 
v2
Comments
Robymon 11-Mar-15 4:52am    
what is "addy"

byte[] arrReturn = client.UploadFile(addy, filePath);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900