当前位置: 代码迷 >> Delphi >> asp.net中下传多个文件
  详细解决方案

asp.net中下传多个文件

热度:9768   发布时间:2013-02-25 00:00:00.0
asp.net中上传多个文件
谁能给点多文件上传的例子,谢谢啦
------解决方案--------------------------------------------------------
   public static string  CreateUploadFile(string FileOlder)
    {
      
         HttpPostedFile postedfile;

        HttpFileCollection file1 = HttpContext.Current.Request.Files;

        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        System.Diagnostics.Stopwatch st = new System.Diagnostics.Stopwatch();
        st.Start();
        for (int i = 0; i < file1.Count; i++)
        {
            postedfile = HttpContext.Current.Request.Files[i];

            //获取文件的扩展名
             FileEx=Path.GetExtension(postedfile.FileName);

            //追加文件名
           

            ////定义文件名以时间命名加上文件扩展名
             string saveFile= DateTime.Now.ToString("yyyyMMddHHmmss")+st.ElapsedTicks.ToString() + FileEx;
             sb.Append(saveFile);
             sb.Append(",");

            //保存文件
             postedfile.SaveAs(HttpContext.Current.Server.MapPath(FileOlder + "/") + saveFile);

        }
        if(sb.Length>0)
        sb.Remove(sb.Length-1, 1);
   
        st.Stop();

        return sb.ToString();
 
    }
  相关解决方案