日期:2014-05-17  浏览次数:20824 次

◆C#实现批量下载◆
邮件表EmailDB中,邮件的附件以二进制流的形式保存在Files(image 类型)字段中,在页面中要实现勾选邮件的标题批量下载邮件的附件到指定文件夹,如何实现??!!
我用以下方法实现批量下载,只能下载第一个附件:
protected void btDownLoad_Click(object sender, EventArgs e)
{
                  string _ID = "";
                foreach (GridViewRow gv in GridView1.Rows)
                {
                    CheckBox cb = (CheckBox)gv.FindControl("CheckBox1");
                    if (cb.Checked)
                    {
                        int index = gv.RowIndex;
                        DataKey key = this.GridView1.DataKeys[index];//获取主键
                        Int64 GVID = Convert.ToInt64(key.Values["ID"]);
                        _ID += GVID.ToString() + ",";
                    }
                }
                if (_ID == "")
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "click", "alert('请选择要下载的报告!')", true);
                }
                else
                {
                    int count = _ID.Split(',').Length - 1;
                    string[] AID = new string[count];
                    AID = _ID.Split(',');
                    for (int i = 0; i < count; i++)
                    {