Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Problem is: invalid username or password or network path not found.

What I have tried:

using (var client = new System.Net.WebClient())
{
    client.Credentials = new System.Net.NetworkCredential("username", "password");

    var localPath = @"\\xxx.xxx.xxx.xxx\folder\MineFile.txt";
    var remotePath = "https://test.com:xxxx/folder/MineFile.txt";

    client.DownloadFile(remotePath, localPath);
}
Posted
Updated 23-Jan-20 22:09pm
Comments
F-ES Sitecore 24-Jan-20 5:33am    
The Credentials will be for accessing the remote file to download, not access to the UNC you are saving to. The context your code is running under will need write access to the UNC. If it doesn't you might need to download the file locally then use another mechanism that allows you to copy files to a UNC while providing credentials.

1 solution

You can't do it directly - the second parameter is not a URI, it's a local file path.
So download it to your local machine, then upload it to the second domain.
 
Share this answer
 
Comments
F-ES Sitecore 24-Jan-20 5:33am    
I think you've misread the code, the params are not used in the order they are defined.

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