上传多个附件delete.gif,a.txt数据库字段ID中的内容
/Attachments/201007/201007111632033125.gif,/Attachments/201007/201007111632034218.txt
Name中的内容
delete,a下载时,单个文件可以。
当两个文件时,我该如何做?怎样将字段中的数据分割开?
谢谢大家!

解决方案 »

  1.   

    string str="";//ID值
    foreach(string s in str.Split(new string[]{",",StringSplitOptions.RemoveEmptyEntries))
    {
     
    }
    遍历下载或压缩多文件实现下载rar,Server.MapPath实现路径
    string filePath ="";
    FileInfo Fi = new FileInfo(filePath);
    if (Fi.Exists)
    {
      FileStream fs = new FileStream(filePath, FileMode.Open);
      byte[] bytes = new byte[(int)fs.Length];
      fs.Read(bytes, 0, bytes.Length);
      fs.Close();
      Response.ContentType = "application/octet-stream";
      Response.AddHeader("Content-Disposition", "attachment; filename=1.excel");
      Response.BinaryWrite(bytes);
      Response.Flush();
      Response.End();
    }
    string path = Server.MapPath("~/") + "";
    Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(obj.Name, System.Text.Encoding.GetEncoding("utf-8")));
    Response.ContentType = "application/octet-stream";
    Response.WriteFile("" + path + "");
    Response.End();