我现在有一个c/s的程序,要求可以调用某一个网页进行文件上传。1.c/s程序可以调用这个网页,网页用的是file控件,但现在我无法实现自动上传,总是要弹出对话框进行选择,请大家指点。2.如果这种方法无法实现,请大家指点一下用别的方式如何实现,目的就是要做到调用这个网页,向这个网页传一个文件名,这个网页可以自动上传此文件到服务器,请大家指点。谢谢。

解决方案 »

  1.   

    use "WebClient" class to upload your file
      

  2.   

    to Knight94(愚翁) 可否给个例子看一下。。
      

  3.   

    string fileName = "c:\\1.xml";
    string uriString = "http://localhost/yj/receivefile/1.xml";  WebClient myWebClient = new WebClient();
    try
    {
    myWebClient.UploadFile(uriString,"POST",fileName);
    }
    catch(Exception err)
    {
    Button1.Text  = err.Message;
    }出现“远程服务器返回错误: (401) 未经授权”,在网上找了一些解决方法,都不好用,请大家指点一下。。