/// <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")); }
时间: 2024-10-12 14:44:51