单个下载,搜到了string fileName = FrameWork.BusinessFacade.GetContractAttachement(long.Parse(s));//客户端保存的文件名
                string filePath = Server.MapPath(Common.UpLoadDir + "ContractFiles/" + fileName);//路径                FileInfo fileInfo = new FileInfo(filePath);
                Response.Clear();
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
                Response.AddHeader("Content-Length", fileInfo.Length.ToString());
                Response.AddHeader("Content-Transfer-Encoding", "binary");
                Response.ContentType = "application/octet-stream";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                Response.WriteFile(fileInfo.FullName);
                Response.Flush();
                Response.End();批量下载怎么弄啊,多了filename

解决方案 »

  1.   

    这是批量上传的例子http://blog.csdn.net/todototry/article/details/8134794
    循环逐个下载即可
    个人意见,高手多多指教
      

  2.   


    /// <summary>
            /// 压缩文件
            /// </summary>
            /// <param name="DFilePath">需要压缩的文件夹或者单个文件</param>
            /// <param name="DRARName">生成压缩文件的文件名</param>
            /// <param name="DRARPath">生成压缩文件保存路径</param>
            /// <returns></returns>
            public static bool RAR(string DFilePath, string DRARName, string DRARPath)
            {
                String the_rar;
                RegistryKey the_Reg;
                Object the_Obj;
                String the_Info;
                ProcessStartInfo the_StartInfo;
                Process the_Process;
                try
                {
                    the_Reg = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\Shell\Open\Command");
                    the_Obj = the_Reg.GetValue("");
                    the_rar = the_Obj.ToString();
                    the_Reg.Close();
                    the_rar = the_rar.Substring(1, the_rar.Length - 7);
                    the_Info = " a    " + " " + DRARName + "  " + DFilePath + " -ep1"; //命令 + 压缩后文件名 + 被压缩的文件或者路径
                    the_StartInfo = new ProcessStartInfo();
                    the_StartInfo.FileName = the_rar;
                    the_StartInfo.Arguments = the_Info;
                    the_StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                    the_StartInfo.WorkingDirectory = DRARPath; //RaR文件的存放目录。
                    the_Process = new Process();
                    the_Process.StartInfo = the_StartInfo;
                    the_Process.Start();
                    the_Process.WaitForExit();
                    the_Process.Close();
                    return true;
                }
                catch
                {
                    return false;
                }
            }
    public static bool DownLoadFile(string _FilePath, string _FileName,HttpResponseBase Response)
            {
                try
                {
                   System.IO.FileStream fs = System.IO.File.OpenRead(_FilePath + _FileName);
                    byte[] FileData = new byte[fs.Length];
                    fs.Read(FileData, 0, (int)fs.Length);
                    Response.Clear();
                    Response.AddHeader("Content-Type", "application/ms-word");
                    string FileName = System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(_FileName));
                    Response.AddHeader("Content-Disposition", "inline;filename=" + System.Convert.ToChar(34) + FileName + System.Convert.ToChar(34));
                    Response.AddHeader("Content-Length", fs.Length.ToString());
                    Response.BinaryWrite(FileData);
                    fs.Close();
                    //删除服务器临时文件
                    System.IO.File.Delete(_FilePath + _FileName);
                    Response.Flush();
                    Response.End();
                    return true;
                }
                catch (Exception ex)
                {
                   // ex.Message.ToString();
                    throw ex;
                    return false;
                }
                
            }
          string path =@"D:\\File"; 
          string rarName="aa";
          if(RAR(path , rarName, path )){
             DownLoadFile(newpath, rarName + ".rar", Response)
          }
      

  3.   

    这个注释太少了,没看明白
    RegistryKey,ProcessStartInfo 这些都是你自己的类库吧
      

  4.   

    http://topic.csdn.net/u/20121015/08/c78078e9-d1a3-4252-b0e3-3d59dc946eca.html?84434
    该工具类很全,其中有个SharpZip.cs 注释还行。
    随便问答一下lz的问题,RegistryKey 引用一下 Microsoft.Win32就找到
      

  5.   

    使用 Ionic.Zip.dll 打包单个文件,再输出打包文件。
      

  6.   


    web不能选择下载的文件,只能在服务器指定发送那些文件给用户
    zip压缩
    文件下载就不说了。不要没看就说看不懂,如果不耐着性子去看,永远也看不懂
      

  7.   

    正解http://www.189works.com/article-60454-1.html
    这个确实好