winform 使用 webclient 上传

 

 

  public void ProcessRequest(HttpContext context)
        {
            HttpPostedFile file = context.Request.Files[0];
            file.SaveAs(context.Server.MapPath("~/uploadimages/") + file.FileName);
        }

 

     string strurl = "http://localhost/Provider/HandlerUpImage.ashx";

           
                WebClient webclient = new WebClient();

                byte[] buffer = webclient.UploadFile(strurl, "POST", @"C:\a.txt");
                using (FileStream fs = new FileStream(@"C:\a.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite))
                {
                    fs.Write(buffer, 0, buffer.Length);
                }

  

posted on 2013-06-10 09:26  gwazy  阅读(517)  评论(0编辑  收藏  举报

导航