Problem generating files within a ZIP

0

I have generated this method with the parameters brought from my database management class, the problem is that I can generate my ZIP file without any problem but I do not have any html file.

 public static string Execute(Models.ReportTibaTimeModel _report, string PathTemplate, string PathFile, string Pass)
    {
        string sFile = string.Empty;

        ReportesBL _rpt = new ReportesBL();
        DataSet ds = _rpt.ReportTibaTime( _report.ProgramName == null? "_": _report.ProgramName, _report.EpiFeatureName == null? "_": _report.EpiFeatureName, _report.HouseNumber == null? "_":_report.HouseNumber);

        if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
        {
            MaestrosBL _maestros = new MaestrosBL();

            sFile = string.Format("{0}_{1}.zip", _report.usuario.Trim(), DateTime.Now.ToString("yyyyMMddHHmmss"));

            string PathFolder = PathFile + sFile.Substring(0, sFile.Length - 6);
            if (System.IO.Directory.Exists(PathFolder))
                System.IO.Directory.Delete(PathFolder);

            Directory.CreateDirectory(PathFolder);


            foreach (DataRow drAdv in ds.Tables[0].Rows)
            {

                //aqui empezamos a zamparle a aquel (HTM) todaaaaa la data 
                DataTable dt = new DataTable();

                dt.Columns.Add("SEGMENTS");
                dt.Columns.Add("HOUSE_NUMBER");
                dt.Columns.Add("NATURAL_START_TIME");
                dt.Columns.Add("NATURAL_END_TIME");
                dt.Columns.Add("SLOT_DURATION");
                dt.Columns.Add("SEGMENT_NAME");
                dt.Rows.Add(new object[] { "a", "b", "c", "d", "f", "g" });
                dt.Rows.Add(new object[] { "h", "i", "j", "k", "l", "m" });


                string tab = "\t";

                StringBuilder sb = new StringBuilder();

                sb.AppendLine("<html>");
                sb.AppendLine(tab + "<body>");
                sb.AppendLine(tab + tab + "<table>");

                // aqui termino de hacer el header
                sb.Append(tab + tab + tab + "<tr>");

                foreach (DataColumn dc in dt.Columns)
                {
                    sb.AppendFormat("<td>{0}</td>", dc.ColumnName);
                }

                sb.AppendLine("</tr>");

                // parte de mi data rows
                foreach (DataRow dr in dt.Rows)
                {
                    sb.Append(tab + tab + tab + "<tr>");

                    foreach (DataColumn dc in dt.Columns)
                    {
                        string cellValue = dr[dc] != null ? dr[dc].ToString() : "";
                        sb.AppendFormat("<td>{0}</td>", cellValue);
                    }

                    sb.AppendLine("</tr>");
                }

                sb.AppendLine(tab + tab + "</table>");
                sb.AppendLine(tab + "</body>");
                sb.AppendLine("</html>");

                System.IO.StreamWriter file = new System.IO.StreamWriter(PathFolder + "\" + "cuquitas.htm");

                file.WriteLine(sb.ToString());
                file.Close();

            }

            Helper.ZipFolder(PathFolder, PathFile, sFile);
         }
       return sFile;

 } 
    
asked by Cris Valdez 05.12.2016 в 15:53
source

0 answers