我在尝试将文件上传到ft时遇到以下异常:WebClient请求期间发生异常。
protected void UploadFile(string ftpServer, string filename)
{
using (System.Net.WebClient client = new System.Net.WebClient())
{
client.Credentials = new System.Net.NetworkCredential("username", "password");
client.UploadFile(ftpServer + new FileInfo(filename).Name, "STOR", filename);
}
}
正在从以下方式访问上述方法:
try
{
UploadFile("ftp://website//Images//",FileUpload1.FileName);
}
catch (Exception ex)
{
ShowError(ex.Message);
}
错误详情:
无法找到文件'C:\ Program Files(x86)\ Common Files \ Microsoft 共享\ DevServer \ 10.0 \ test.jpg放在”。
PS:文件位于图片文件夹中,而不是上面的给定文件夹。