首页 > 其他 > 详细

导出txt格式的说明书

时间:2015-11-28 14:56:55      阅读:255      评论:0      收藏:0      [点我收藏+]
/// <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"));
        }

导出txt格式的说明书

原文:http://www.cnblogs.com/yinchuan/p/5002591.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!