WebClient client = new WebClient();
string txt = client.DownloadString("http://localhost/test.html");
txt = txt + "啦啦阿拉拉拉啦啦啦啦阿拉拉拉拉拉爱啦啦阿拉啦啦阿拉阿里";
byte[] byts = System.Text.Encoding.Default.GetBytes(txt);
Stream stream = client.OpenWrite("http://localhost/test11.html","PUT");
stream.Write(byts, 0, byts.Length);
stream.Close();
stream.Dispose();
如果遇到405问题,考虑一下几点:
1,服务里面启用 WebClient服务
2,iis 里面FileUpLoad文件夹在 iis和物理文件夹属性上都设置允许匿名帐号可以修改
3,上传的路径必须是http://localhost:8011/FileUpLoad/xx.jpg,不能只是 http://localhost:8011/FileUpLoad/
4,iis属性里面。允许PUT动作,
注意这4点,应该是完全可以实现上传了
from:http://social.msdn.microsoft.com/Forums/zh-CN/295/thread/54eadf9d-71a2-4196-9eb1-969612ca81f3