/// <summary>
        /// 说明书
        /// </summary>
        /// <returns></returns>
        public FileResult ExportPackageInfo()
        {
            List<Aniuge_spu> spuList = ProductBusiness.GetInstance().GetProdutInfo();
            string zipName = DateTime.Now.ToString("yyyyMMddHHmmss");
            string filepath = Server.MapPath("~/upload/PackageInsert") + zipName;
            if (!System.IO.Directory.Exists(filepath))
                System.IO.Directory.CreateDirectory(filepath);

            foreach (var item in spuList)
            {
                FileStream file = new FileStream(filepath + "\\" + item.Code + ".txt", FileMode.Create, FileAccess.Write);
                StreamWriter sw = new StreamWriter(file);
                sw.WriteLine(item.PackageInsert);
                sw.Close();
                fileClose();
            }

            ZipOperateHelper.Zip(filepath, Server.MapPath("~/upload/PackageInsert/") + "\\" + zipName + ".txt", "");
            //下载
            return File(new FileStream(filepath + ".zip", FileMode.Open), "application/octet-stream", Server.UrlEncode(zipName + ".zip"));
        }
posted on 2015-11-28 13:52  三人之行,必有我师  阅读(290)  评论(0编辑  收藏  举报