使用文件上传控件的postingfiles属性从asp.net 4.0中的两个fileupload控件上传多个文件

时间:2015-09-04 11:19:51

标签: c# asp.net

我有两个文件上传控件   这是保存多个文件的代码 C#  string filepath = Server.MapPath(“〜// Files / Documents / test /”);         HttpFileCollection uploadedFiles = Request.Files;

    //Span1.Text = string.Empty;

    for (int i = 0; i < uploadedFiles.Count; i++)
    {
        HttpPostedFile userPostedFile = uploadedFiles[i];

        try
        {
            if (userPostedFile.ContentLength > 0)
            {
                Response.Write(userPostedFile.FileName);

                userPostedFile.SaveAs(filepath  + Path.GetFileName(userPostedFile.FileName));                  
                //Span1.Text += "Location where saved: " +   filepath + "\\" +   Path.GetFileName(userPostedFile.FileName) + "<p>";
            }
        }

        catch (Exception Ex)
        {
            //Span1.Text += "Error: <br>" + Ex.Message;
        }
    }

0 个答案:

没有答案