我正在尝试将文件发送到我们的一台服务器,但我不断收到错误“找不到网络路径”。下面是我用来发送文件的代码
try
{
Console.WriteLine("Uploading file to server....Please wait!!");
WebClient client = new WebClient();
NetworkCredential nc = new NetworkCredential(userName, password, "domain");
Uri address = new Uri(@"\\126.00.00.01\MyFolder\test.txt");
client.Credentials = nc;
string fullpath = Path.Combine(Directory.GetCurrentDirectory(), filePath);
byte[] arrReturn = client.UploadFile(address, fullpath);
Console.WriteLine("File uploaded sucessfully");
System.Threading.Thread.Sleep(2000);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
System.Threading.Thread.Sleep(5000);
}
请问我做错了什么。服务器在测试时似乎可以在 Windows 资源管理器上运行。