我想要实现的功能就是将C盘的11.docx文档上传到服务器地址http://localhost:8010/的DOC文件夹内,并以hello.docx重命名保存。调用的是WebClient的UploadFile方法,参数(string address,string method,string fileName),始终会出现远程服务器返回错误:404未找到.注,调用下载方法时,能从服务器成功下载
public static bool Upload( string newFileName)
{
WebClient myWebClient = new WebClient();
myWebClient.Credentials = CredentialCache.DefaultCredentials;
try
{
myWebClient.UploadFile("http://localhost:8010/DOC/hello.docx", "PUT", @"C:\11.docx");
}
catch (Exception e)
{
MessageBox.Show("文件上传失败,请稍后重试");
return false;
}
return true;
}c#WebClientUploadFile
public static bool Upload( string newFileName)
{
WebClient myWebClient = new WebClient();
myWebClient.Credentials = CredentialCache.DefaultCredentials;
try
{
myWebClient.UploadFile("http://localhost:8010/DOC/hello.docx", "PUT", @"C:\11.docx");
}
catch (Exception e)
{
MessageBox.Show("文件上传失败,请稍后重试");
return false;
}
return true;
}c#WebClientUploadFile
Resolve 404 in IIS Express for PUT and DELETE Verbs
http://geekswithblogs.net/michelotti/archive/2011/05/28/resolve-404-in-iis-express-for-put-and-delete-verbs.aspx