我正在尝试将文件上传到远程计算机获取异常
(530)未登录
using (WebClient webClient = new WebClient())
{
string filePath = "D:/CLIENT/12345.txt";
webClient.UploadFile("ftp://10.10.10.21/var/www/webdav/12345.txt","STOR", filePath);
}
有人可以帮忙吗?
答案 0 :(得分:0)
@Mainak,您需要为FTP服务器提供凭证,以便它可以验证您是否允许访问它。试试这个:
using (WebClient webClient = new WebClient())
{
string filePath = "D:/CLIENT/12345.txt";
webClient.Credentials = new NetworkCredential("ftpusername", "ftpuserpassword");
webClient.UploadFile("ftp://10.10.10.21/var/www/webdav/12345.txt","STOR", filePath);
}