【发布时间】:2015-09-11 22:40:07
【问题描述】:
string uploadPath = "http://10.126.64.230/home/pi/Videos/";
WebClient webclient = new WebClient();
CredentialCache cc = new CredentialCache();
Uri uri = new Uri("http://10.126.64.230/pi");
NetworkCredential nc = new NetworkCredential();
nc.Domain = "root";
nc.UserName = "pi";
nc.Password = "posix";
cc.Add(
uri,
"NTLM",
nc);
webclient.Credentials = cc;
//System.Text.Encoding.ASCII.GetString(responseArray);
bool cntrl = System.IO.File.Exists(uploadPath + this.FuplVideo.FileName);
if (cntrl)
{
// fileName = uploadPath + this.FuplVideo.FileName + DateTime.Now.ToString("yyyy-MM-dd HHmmtt") + ext;
// webclient.UploadFile(uploadPath, "POST", fullFilePath);
}
else
{
webclient.UploadFile(uploadPath, "POST", fullFilePath);
}
我尝试将文件发送到与 LAN 连接的机器。但我用不同版本的域尝试这段代码,我得到了
"System.Net.Sockets.SocketException 因为目标没有连接 机器拒绝”
每次都出错。你有什么建议?
【问题讨论】:
-
如何使用 System.IO 读取 httpPath? bool cntrl = System.IO.File.Exists(uploadPath + this.FuplVideo.FileName)?如果其 netqork 使用 UNC:\\10.126.64.230\home\pi\Videos\
-
我会在修复此错误后将其删除。
标签: c# webclient socketexception