WebClient myWebClient = new WebClient();
            FolderBrowserDialog fbDialog = new FolderBrowserDialog();
            if (fbDialog.ShowDialog() == DialogResult.OK)
            {
                string directoryPath = fbDialog.SelectedPath;
                string[] fn = Directory.GetFiles(directoryPath);//E:\李四\区划所\样方数据\玉米\ym2011yj\photo\ym370082011
                foreach (string s in fn)//E:\李四\区划所\样方数据\玉米\ym2011yj\photo\ym370082011\ym370082011EEF.JPG
                {
                    myWebClient.UploadFile("http://localhost/WebSite/Default.aspx", "POST", s);
                }
            }
ym370082011下有几张图片,遍历传递至服务器中,想要把ym370082011文件夹也穿过去这个如何做啊

解决方案 »

  1.   

    这个是另一种方法,把文件夹压缩传过去,不知道为啥不能穿过去,文件压缩就可以myWebClient.UploadFile("http://localhost/WebSite/Default.aspx", "POST", @"D:\TDDOWNLOAD\ym370082011.zip");网站代码
    protected void Page_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < Request.Files.Count; i++)
            {
                string extension = System.IO.Path.GetExtension(Request.Files[i].FileName);
                Guid g_ = Guid.NewGuid();
                string fileName = g_.ToString() + extension;
                string fileP=Server.MapPath("~/files/");
                string filePath = Server.MapPath("~/files/") + fileName;
                Request.Files[i].SaveAs(filePath);
                if (extension == ".zip")
                { 
                    string err;
                    UnZipFile(filePath, fileP, out err);
                }
                
                Response.Write(fileName);
                Response.End();
            }
            
        }不知道出错在哪,各位帮忙看看
      

  2.   

    知道怎么错了,是asp.net上传限制的原因,如何修改上传文件大小呢
      

  3.   


    搜索asp.net 上传限制