Пример #1
0
        /// <summary>
        /// download more than one files
        /// </summary>
        /// <param name="context"></param>
        private void Downloads(HttpContext context)
        {
            //define the zip file's location [target container]
            string zipFile = context.Server.MapPath("#download.zip");

            string[]      fd    = context.Request["value1"].Split('|');
            List <string> files = new List <string>();
            List <string> dirs  = new List <string>();

            foreach (string item in fd)
            {
                string p = context.Server.MapPath(item);
                if (File.Exists(p))
                {
                    files.Add(p);
                }
                else if (Directory.Exists(p))
                {
                    dirs.Add(p);
                }
            }
            //create zip package
            ZipClass.Zip(Path.GetDirectoryName(zipFile) + "\\", zipFile, "",
                         true, files.ToArray(), dirs.ToArray());
            DownLoadFIle.ResponseFile(zipFile, context, false);
        }
Пример #2
0
        /// <summary>
        /// 下载文件操作
        /// </summary>
        /// <param name="context"></param>
        private void DownLoadFile(HttpContext context)
        {
            string value1 = context.Request["value1"];

            //split the file address
            string[] files = value1.Split('|');
            foreach (string item in files)
            {
                //get the absolute address
                string path = context.Server.MapPath(item);
                if (File.Exists(path))
                {
                    DownLoadFIle.ResponseFile(path, context, true);
                }
            }
        }